Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drop all triggers within given DB in Oracle at once?

How to drop (remove, delete) all triggers within given DB.

Problem is that application requires DB upgrade and does not proceed triggers (suport, drop, create) after upgrade, application upgrade fails.

like image 574
user1025759 Avatar asked Nov 02 '11 13:11

user1025759


People also ask

How do you view and drop all triggers in a given database?

USE YourDBName GO SELECT ' GO ' + Char(10) + Char(13) + 'DROP TRIGGER ' + QUOTENAME(OBJECT_SCHEMA_NAME(O. [object_id])) + '. ' + QUOTENAME(name) FROM sys. sql_modules as M INNER JOIN sys.

How do I drop a trigger in Oracle?

Use the DROP TRIGGER statement to remove a database trigger from the database. The trigger must be in your own schema or you must have the DROP ANY TRIGGER system privilege. To drop a trigger on DATABASE in another user's schema, you must also have the ADMINISTER DATABASE TRIGGER system privilege.

Which command disables all the triggers on a specific table?

Use the ALTER TRIGGER statement to enable, disable, or compile a database trigger.

How many triggers can be dropped in a single command?

How many triggers can be dropped in a single command? A single SQL statement can potentially fire up to four types of triggers: BEFORE row triggers.


2 Answers

This will generate the command how to drop all triggers in current schema:

select 'drop trigger ' || trigger_name || ';' stmt from user_triggers;
like image 186
Bjarte Brandt Avatar answered Oct 09 '22 08:10

Bjarte Brandt


You can create a script for dropping triggers by using the Oracle system tables, like this:

select 'drop trigger ' || owner || '.' || trigger_name || ';' from all_triggers

Note that there are 3 views containing triggers:

  • all_triggers = all the triggers you have permission to know about (regardless of which schema they belong to)
  • user_triggers = the triggers that belong to your own schema
  • dba_triggers = for DBA's
like image 30
GTG Avatar answered Oct 09 '22 08:10

GTG