Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Views, Stored Procedures and Triggers

1 topic ยท 28 Nov 2026
1

Views, Stored Procedures and Triggers

Database
SQL
-- View: a saved query that behaves like a table
CREATE VIEW top_students AS
SELECT name, cgpa FROM students WHERE cgpa >= 3.75;

-- Stored procedure: saved, reusable SQL with parameters
DELIMITER //
CREATE PROCEDURE get_dept_students(IN d INT)
BEGIN
    SELECT * FROM students WHERE dept_id = d;
END //
DELIMITER ;
CALL get_dept_students(10);

-- Trigger: runs automatically on INSERT / UPDATE / DELETE
CREATE TRIGGER before_student_insert
BEFORE INSERT ON students
FOR EACH ROW SET NEW.name = UPPER(NEW.name);