CodesJava

Easy learning with example program codes

DISABLE TRIGGER in Oracle

ORACLE DISABLE TRIGGER
As the name itself suggests, this type of trigger is used to disable an already existing or newly created trigger for a table from the database. To serve this purpose ALTER TRIGGER statement is used.

Syntax:

ALTER TRIGGER trigger_name DISABLE;     

Parameters:
trigger_name: It is used to specify the name of the trigger to be created.

Example:
Students Table:

STUDENT_ID	STUDENT_NAME	STUDENT_AGE
1	        Joy	        20
2	        Smiley	        19
3	        Happy	        21
4	        James	        22
5	        Bond	        25

Create Trigger code:

CREATE OR REPLACE TRIGGER  "STUDENTS_T"   
AFTER INSERT or UPDATE or DELETE    
ON "STUDENTS"   
FOR EACH ROW
BEGIN  
WHEN the person performs insert/update/delete operations into the table.  
END;  
/  
ALTER TRIGGER  "STUDENTS_T" DISABLE  
/

Output:

TRIGGER NAME	TRIGGER TYPE	 TRIGGERING EVENT	         STATUS
STUDENTS_T	AFTER EACH ROW	 INSERT or UPDATE or DELETE	 DISABLED

Explanation:
The ‘students’ is an already existing table and a trigger is created with the name “STUDENTS_T”. But even AFTER the INSERT, UPDATE or DELETE statement is issued on the table “STUDENTS”, the Oracle database will not fire the trigger, since it is in the DISABLED mode.

Please follow and like us:
error









Copyright © 2019 CodesJava DMCA.com Protection Status