clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36311 in the last week).

CREATE TABLE table1 (id INT, val CHAR(1)); INSERT INTO table1 VALUES (1,'a'), (2,'b'), (3,'c'); SELECT * FROM table1; CREATE TABLE table2 LIKE table1; INSERT INTO table2 SELECT * FROM table1; SELECT * FROM table2;
id val
1 a
2 b
3 c
id val
1 a
2 b
3 c
 hidden batch(es)


CREATE TRIGGER tr_au_t2 AFTER UPDATE ON table2 FOR EACH ROW INSERT INTO table1 (id, val) VALUES (NEW.id, NEW.val);
 hidden batch(es)


UPDATE table2 SET val = 'z' WHERE id = 2; SELECT * FROM table1; SELECT * FROM table2;
id val
1 a
2 b
3 c
2 z
id val
1 a
2 z
3 c
 hidden batch(es)