Maintain a timestamp on row changes.
Section: Triggers and generated values
Touch updated_at from a trigger
sql
sql
CREATE TRIGGER posts_au
AFTER UPDATE ON posts
BEGIN
UPDATE posts
SET updated_at = CURRENT_TIMESTAMP
WHERE id = NEW.id;
END;Explanation
Be careful to avoid unintended recursive behavior depending on trigger design and settings.
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
Create an AFTER INSERT trigger
Write to an audit log when a row is created.
Normalize data with a generated column
Compute a lowercased email for indexing or search.