L3 Q8 Advanced Level
Practice Question

Level 3 - Question 8: Creating an Audit Trigger

Scenario

Your company needs to track all changes to employee salaries for compliance purposes. You need to automatically log salary changes to an audit table whenever an UPDATE occurs.

Task

Create a trigger that automatically inserts a record into an audit_log table whenever an employee's salary is updated in the employees table.

Sample Schema: employees

emp_id name salary
1 John Doe 70000
2 Jane Smith 65000

Sample Schema: audit_log

log_id emp_id old_salary new_salary change_date
Initially empty