triggers_procedures_flashcards
What is a stored procedure?
Procedural SQL code stored in the database, executed with a CALL statement.
What is a trigger?
A procedure that automatically executes in response to certain events on a table.
When do triggers execute?
On INSERT, UPDATE, or DELETE events.
What are the components of a trigger?
Trigger event, timing (BEFORE/AFTER), and level (ROW/STATEMENT).
How do you declare a procedure in MySQL?
Using CREATE PROCEDURE with input/output parameters and a BEGIN…END block.
What is the difference between a procedure and a trigger?
Procedures are called manually; triggers are event-driven.
What is the use of DELIMITER in MySQL?
To change the statement terminator when defining procedures or triggers.
What is NEW and OLD in triggers?
Pseudo-records to reference column values before/after a change.