Write to an audit log when a row is created.
Section: Triggers and generated values
Create an AFTER INSERT trigger
sql
sql
CREATE TRIGGER users_ai
AFTER INSERT ON users
BEGIN
INSERT INTO audit_log(entity, entity_id, action)
VALUES ('users', NEW.id, 'insert');
END;Explanation
A classic pattern for audit trails and event capture.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Triggers and generated values