Oracle: SQL query to find all the triggers belonging to the tables?
To unearth all the triggers associated with the tables in your Oracle schema, conduct a quick investigation on the ALL_TRIGGERS
view:
Swap 'YOUR_SCHEMA' with your schema name. This command disgorges the trigger names, their associated tables, and the statuses echoing whether they are enabled or disabled.
Do you not enjoy the privileges to cross-question ALL_TRIGGERS
? Worry not! You can chit-chat with DBA_TRIGGERS
with your DBA privileges or get insider info from USER_TRIGGERS
to catalogue triggers spawned by the current user.
Unlocking multiple triggers and diverse schemas
Ordering multiple triggers
Fancy a table with multiple triggers? Be Sherlock. Analyze the order of firing the triggers. Remember, they follow a sportsmanship spirit when they belong to the same timing/event combination (BEFORE UPDATE, for instance). Your ally here - trigger_order
column from the ALL_TRIGGERS
view.
Navigating through schema variations
- Peeping into another's schema:
SELECT * FROM all_triggers WHERE table_owner = 'ANOTHER_SCHEMA';
Not spying, just browsing! - Self-introspection:
SELECT * FROM user_triggers;
See the triggers answering to user you.
Super-efficient trigger management
Opt for these queries for peak performance in handling triggers:
- Status-check: Regular patrol to ensure triggers are enabled or disabled as per your wish.
- Event attendance: Stay aware of the triggers' presence at the triggering event (INSERT, UPDATE, DELETE, TRUNCATE). Find them using
SELECT triggering_event FROM all_triggers;
. - Timing specs:
SELECT trigger_type FROM all_triggers;
precisely tells you the timing of the triggers (BEFORE, AFTER, INSTEAD OF).
Finding triggers sprawled across schemas
Unearth triggers around all schemas:
Avail a full identifier that seamlessly blends the schema and trigger name.
References
Was this article helpful?