1DROP TABLE mdt; 2 3CREATE TABLE mdt ( 4 id int4, 5 idesc text, 6 moddate timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL 7); 8 9CREATE TRIGGER mdt_moddatetime 10 BEFORE UPDATE ON mdt 11 FOR EACH ROW 12 EXECUTE PROCEDURE moddatetime (moddate); 13 14INSERT INTO mdt VALUES (1, 'first'); 15INSERT INTO mdt VALUES (2, 'second'); 16INSERT INTO mdt VALUES (3, 'third'); 17 18SELECT * FROM mdt; 19 20UPDATE mdt SET id = 4 21 WHERE id = 1; 22UPDATE mdt SET id = 5 23 WHERE id = 2; 24UPDATE mdt SET id = 6 25 WHERE id = 3; 26 27SELECT * FROM mdt; 28