Notice that if you drop a table, all associated triggers are also deleted.
Now before updating ’empid’ column in ’emp’ table see the ’emp’ and ’emp_backup’ table records.
Vishwanath Dalvi is a gifted engineer and tech enthusiast. When not hacking around or supporting the open source community, he is trying to overcome his phobia of dogs.
For example, you want to log the changes of the sensitive data such as salary, address, etc., whenever it changes.
In addition, you use triggers to enforce complex business rules centrally at the database level and prevent invalid transactions.
CREATE or REPLACE TRIGGER emp_after_update AFTER UPDATE OF empid ON emp FOR EACH ROW DECLARE BEGIN update emp_backup set empid = :new.empid where empid = :old.empid; DBMS_OUTPUT.
PUT_LINE('empid successfully updated into emp_backup table'); END; The above trigger named ’emp_after_update’ will be initiated whenever ’empid’ column in ’emp’ table gets updated.
, Inter Base increments the metadata change counter of the associated table.
Once that counter reaches 255, no more metadata changes are possible on the table (you can still work with the data though).
An SQLite trigger is a named database object that is executed automatically when an INSERT, UPDATE, or DELETE statement is issued against the associated table.
You often use triggers to enable sophisticated auditing.
For example, when a new record (representing a new worker) is added to the employees table, new records should also be created in the tables of the taxes, vacations and salaries.