It specifies how to create trigger after delete the data. We have two tables COMPANY and AUDIT.
CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL );
CREATE TABLE AUDIT( EMP_ID INT NOT NULL, ENTRY_DATE TEXT NOT NULL );
CREATE trigger after delete:
Use the following syntax to create a trigger named "after_del" on COMPANY table after delete operation.
CREATE TRIGGER after_del AFTER DELETE ON COMPANY BEGIN INSERT INTO AUDIT(EMP_ID, ENTRY_DATE) VALUES (new.ID, datetime('now')); END;
Now delete the record from the old table:
DELETE FROM COMPANY;
See the trigger:
SELECT name FROM sqlite_master WHERE type = 'trigger';