Recall & Review
beginner
What is an INSERT trigger in SQL?
An INSERT trigger is a special kind of stored procedure that automatically runs when a new row is added to a table.
Click to reveal answer
beginner
When does an INSERT trigger execute?
It executes immediately after or before a new row is inserted into a table, depending on how the trigger is defined.
Click to reveal answer
intermediate
Can an INSERT trigger modify the data being inserted?
Yes, a BEFORE INSERT trigger can change the data before it is saved, while an AFTER INSERT trigger cannot modify the inserted data but can act on it.
Click to reveal answer
beginner
Give a simple example of an INSERT trigger use case.
A trigger that automatically adds the current date and time to a 'created_at' column whenever a new row is inserted.
Click to reveal answer
intermediate
What happens if an INSERT trigger raises an error?
The insert operation is rolled back, and the new row is not added to the table.
Click to reveal answer
What does an INSERT trigger do?
✗ Incorrect
An INSERT trigger runs automatically when a new row is inserted into a table.
When is a BEFORE INSERT trigger executed?
✗ Incorrect
A BEFORE INSERT trigger runs before the new row is saved to the table.
Can an AFTER INSERT trigger modify the inserted data?
✗ Incorrect
AFTER INSERT triggers run after data is inserted and cannot change the inserted row.
What happens if an INSERT trigger causes an error?
✗ Incorrect
If a trigger raises an error, the insert operation is canceled and rolled back.
Which of these is a common use for an INSERT trigger?
✗ Incorrect
INSERT triggers often add timestamps or log information when new rows are added.
Explain what an INSERT trigger is and when it runs.
Think about what happens automatically when you add a new row.
You got /2 concepts.
Describe a practical example where you might use an INSERT trigger.
Consider adding timestamps or logging new data.
You got /3 concepts.