What is the correct SQL for a trigger to copy a record to an identical table?

I have two tables TABLE1 and TABLE2 with the same structures. I need a trigger to copy a record after pasting from TABLE1 to TABLE2. What is the correct SQL for this?

+3
source share
1 answer

this would work:

CREATE OR REPLACE TRIGGER copy_tab1_tab2_trg AFTER INSERT ON table1
   FOR EACH ROW
BEGIN
    INSERT INTO TABLE2 
       (col1, col2, ..., coln) 
    VALUES 
       (:NEW.col1, :NEW.col2, ..., :NEW.coln);
END;
+8
source

Source: https://habr.com/ru/post/1743193/


All Articles