简体   繁体   中英

sqlite before delete insert trigger

I would like to save the contents that are just about to get deleted from my Table1 to another identical table called Table2. All fields are identical in both tables. How is the trigger to look like ?

Create a trigger on Table1 (before delete - for each row) :

INSERT INTO [Table2]
    [VALUE1], 
    [VALUE2], 
    [VALUE3] 
  VALUES ([old].[VALUE1], [old].[VALUE2], [OLD].[VALUE3]);

Or you can use classic SQL :

INSERT INTO TABLE2 SELECT * FROM TABLE1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM