Recall & Review
beginner
What is a DELETE trigger in SQL?
A DELETE trigger is a special kind of stored procedure that automatically runs when a DELETE operation happens on a table. It lets you react to row deletions, like logging or preventing the delete.
Click to reveal answer
beginner
When does a DELETE trigger execute?
A DELETE trigger executes immediately before or after a DELETE statement removes rows from a table, depending on whether it is defined as BEFORE DELETE or AFTER DELETE.
Click to reveal answer
intermediate
What is the difference between BEFORE DELETE and AFTER DELETE triggers?
BEFORE DELETE triggers run before the rows are deleted, allowing you to check or modify data. AFTER DELETE triggers run after the rows are deleted, useful for actions like logging the deletion.
Click to reveal answer
intermediate
How can you access the deleted rows inside a DELETE trigger?
Inside a DELETE trigger, you can access the deleted rows using the special table called OLD (in some SQL dialects) or DELETED (in others), which holds the data of the rows being deleted.
Click to reveal answer
beginner
Why would you use a DELETE trigger in a database?
You use a DELETE trigger to automatically perform tasks like auditing deletions, enforcing business rules, preventing accidental deletes, or cleaning up related data when rows are deleted.
Click to reveal answer
What does a DELETE trigger do?
✗ Incorrect
A DELETE trigger runs automatically when rows are deleted from a table.
Which special table holds the deleted rows inside a DELETE trigger?
✗ Incorrect
The OLD table holds the data of the rows being deleted inside a DELETE trigger.
When does an AFTER DELETE trigger run?
✗ Incorrect
An AFTER DELETE trigger runs after the rows have been deleted.
Which of these is NOT a common use of DELETE triggers?
✗ Incorrect
DELETE triggers do not automatically insert new rows; they react to deletions.
Can a DELETE trigger modify the data being deleted before it happens?
✗ Incorrect
BEFORE DELETE triggers can check or modify data before deletion.
Explain what a DELETE trigger is and when it runs.
Think about what happens when you remove rows from a table.
You got /3 concepts.
Describe two practical uses of DELETE triggers in a database.
Why would you want to react automatically when data is deleted?
You got /4 concepts.