开发者

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

开发者 https://www.devze.com 2022-12-28 06:16 出处:网络
I have two tables TABLE1 and TABLE2 with identical struct开发者_StackOverflowures.I need a trigger to copy a record after insert from TABLE1 to TABLE2.What\'s the proper SQL for this?this would work:

I have two tables TABLE1 and TABLE2 with identical struct开发者_StackOverflowures. I need a trigger to copy a record after insert from TABLE1 to TABLE2. What's the proper SQL for this?


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消