0
0
SQLquery~5 mins

INSERT trigger in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AUpdates existing rows only
BDeletes rows from a table
CRuns automatically when a new row is added to a table
DCreates a new table
When is a BEFORE INSERT trigger executed?
ABefore the row is inserted
BAfter the row is inserted
CWhen a row is deleted
DWhen a table is created
Can an AFTER INSERT trigger modify the inserted data?
AYes, it can change the data before insertion
BNo, it only runs on updates
CYes, it deletes the data
DNo, it cannot modify the inserted data
What happens if an INSERT trigger causes an error?
AThe insert still happens
BThe insert is rolled back and does not happen
CThe trigger is ignored
DThe database shuts down
Which of these is a common use for an INSERT trigger?
AAutomatically logging the insert time
BDeleting old rows
CChanging table structure
DBacking up the database
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.