0
0
SQLquery~5 mins

Trigger for audit logging in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of a trigger in audit logging?
A trigger automatically records changes made to a table, such as inserts, updates, or deletes, to keep an audit trail of data modifications.
Click to reveal answer
beginner
Which SQL event types can a trigger listen to for audit logging?
Triggers can listen to INSERT, UPDATE, and DELETE events to capture changes for audit logging.
Click to reveal answer
intermediate
What is a common structure of an audit log table?
An audit log table usually contains columns like action_type (INSERT/UPDATE/DELETE), changed_by (user), changed_at (timestamp), and old/new values of the data.
Click to reveal answer
intermediate
How does a BEFORE trigger differ from an AFTER trigger in audit logging?
A BEFORE trigger runs before the data change happens, allowing validation or modification; an AFTER trigger runs after the change, ideal for recording the final state in audit logs.
Click to reveal answer
beginner
Why is audit logging important in databases?
Audit logging helps track who changed what and when, supporting security, compliance, and troubleshooting by providing a history of data changes.
Click to reveal answer
Which SQL trigger event is NOT typically used for audit logging?
ASELECT
BUPDATE
CDELETE
DINSERT
What information is essential to store in an audit log table?
AUser who made the change
BTimestamp of the change
CType of action performed
DAll of the above
When should an AFTER trigger be used for audit logging?
ATo validate data before change
BTo record the final state after data change
CTo prevent data changes
DTo modify data before insertion
Which SQL statement creates a trigger for audit logging?
ACREATE TRIGGER
BCREATE PROCEDURE
CCREATE FUNCTION
DCREATE VIEW
What is a risk of not having audit logging in a database?
AEasier data recovery
BImproved database performance
CData changes cannot be tracked
DAutomatic backups
Explain how a trigger can be used to implement audit logging in a database.
Think about what happens when data changes and how to capture that automatically.
You got /4 concepts.
    Describe the key columns you would include in an audit log table and why.
    Consider what information helps track who did what and when.
    You got /4 concepts.