PL/SQL What is an trigger and how will create, disable, compile, rename
What is an trigger and how will create, disable, compile, rename
A trigger is a PL/SQL block associated with a table, view or a database scheme. Is executed whenever an event occurs.
Types of triggers:
– triggers for application
– triggers at the database level
CREATE OR REPLACE TRIGGER trigger_name {BEFORE | AFTER | INSTEAD OF} {INSERT | UPDATE | DELETE} [OF column_name] ON table_name [REFERENCING OLD AS old NEW AS new] [FOR EACH ROW] WHEN (condition) BEGIN --- pl/sql code END;
ALTER TRIGGER trigger_name ENABLE; ALTER TRIGGER trigger_name DISABLE; ALTER TRIGGER trigger_name COMPILE; ALTER TRIGGER trigger_name RENAME TO new_trigger_name; ALTER TABLE table_name DISABLE ALL TRIGGERS; ALTER TABLE table_name ENABLE ALL TRIGGERS;