0
0
SQLquery~5 mins

AFTER trigger execution in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an AFTER trigger in SQL?
An AFTER trigger is a database trigger that runs automatically after a specified data modification event like INSERT, UPDATE, or DELETE has completed successfully.
Click to reveal answer
beginner
When does an AFTER trigger execute in relation to the triggering SQL statement?
An AFTER trigger executes only after the triggering SQL statement has completed successfully.
Click to reveal answer
intermediate
Can an AFTER trigger modify the data that caused it to fire?
No, AFTER triggers cannot modify the data that caused them to fire because the original statement has already completed. They can only perform additional actions like logging or cascading changes.
Click to reveal answer
beginner
Give an example use case for an AFTER trigger.
An AFTER trigger can be used to log changes to a table by inserting a record into an audit table after a row is inserted or updated.
Click to reveal answer
intermediate
What happens if an AFTER trigger fails during execution?
If an AFTER trigger fails, the entire transaction that fired the trigger is rolled back, undoing the original data modification.
Click to reveal answer
When does an AFTER trigger run in SQL?
AOnly when a SELECT statement runs
BBefore the data modification statement executes
CAt the same time as the data modification statement
DAfter the data modification statement completes successfully
Which of the following can an AFTER trigger NOT do?
ALog changes to another table
BSend notifications
CModify the data that caused the trigger to fire
DEnforce complex business rules after data change
If an AFTER trigger fails, what happens to the original data change?
AThe data change is rolled back
BOnly the trigger fails, data change is ignored
CThe data change remains committed
DThe database shuts down
Which SQL events can an AFTER trigger be defined on?
AINSERT, UPDATE, DELETE
BSELECT only
CCREATE and DROP
DALTER only
What is a common use of AFTER triggers?
ATo validate data before insertion
BTo log audit information after data changes
CTo speed up SELECT queries
DTo create new tables automatically
Explain what an AFTER trigger is and when it executes in a database.
Think about what happens after you save changes in a spreadsheet.
You got /3 concepts.
    Describe a practical scenario where you would use an AFTER trigger and why.
    Consider tracking changes after they happen.
    You got /3 concepts.