Triggers Flashcards

1
Q

What are Triggers?

A

Triggers are stored programs, which are automatically executed or fired when some events occur

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 2 types of triggers?

A
  • Statement-level trigger

- Row-level Trigger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When does Statement-level triggers fire?

A

Fires once for a statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When does Row-level triggers fire?

A

Will fire for every row that’s effected by a statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What type of trigger uses :OLD and :NEW bind variables?

A

Row-level Trigger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of DDL statement is :OLD meaningless in?

A

INSERT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What type of DDL statement is :NEW meaningless in?

A

DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly