Triggers Flashcards
1
Q
What are Triggers?
A
Triggers are stored programs, which are automatically executed or fired when some events occur
2
Q
What events can be used to execute a trigger?
A
- DML Statement (Delete, Update, Insert)
- DDL Statement (Create, Alter, Drop)
- A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or SHUTDOWN)
3
Q
What is the syntax for creating a trigger?
A
CREATE [OR REPLACE ] TRIGGER trigger_name {BEFORE | AFTER | INSTEAD OF } {INSERT [OR] | UPDATE [OR] | DELETE} [OF col_name] ON table_name [FOR EACH ROW] WHEN (condition) DECLARE Declaration-statements BEGIN Executable-statements EXCEPTION Exception-handling-statements END;
4
Q
What are the 2 types of triggers?
A
- Statement-level trigger
- Row-level Trigger
5
Q
When does Statement-level triggers fire?
A
Fires once for a statement
6
Q
When does Row-level triggers fire?
A
Will fire for every row that’s effected by a statement
7
Q
What type of trigger uses :OLD and :NEW bind variables?
A
Row-level Trigger
8
Q
What type of DDL statement is :OLD meaningless in?
A
INSERT
9
Q
What type of DDL statement is :NEW meaningless in?
A
DELETE