Run a function automatically when rows change.
Section: Views, Functions, Triggers, and Extensions
Create trigger
sql
sql
CREATE TRIGGER trg_users_updated_at
BEFORE UPDATE ON public.users
FOR EACH ROW
EXECUTE FUNCTION set_updated_at();Explanation
See summary for usage details.
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 Views, Functions, Triggers, and Extensions
Create identity column
Use a SQL-standard identity column instead of serial.
Describe a table
Show columns, indexes, defaults, storage details, and more for a relation.