Oracle Database includes several views that contain information about triggers in the database. We can use these views to return a list of triggers.
The user_triggers
View
The user_triggers
view describes the triggers owned by the current user.
Query example:
SELECT
trigger_name,
trigger_type,
triggering_event,
table_owner,
table_name,
base_object_type,
status,
trigger_body
FROM
user_triggers
ORDER BY
trigger_name ASC,
base_object_type ASC,
table_name ASC;
As mentioned, this returns only those triggers that are owned by the current user.
To return more than that, use one of the following views.
The all_triggers
View
The all_triggers
view describes the triggers on tables accessible to the current user.
If the user has the CREATE ANY TRIGGER
privilege, then this view describes all triggers in the database.
SELECT
owner,
trigger_name,
trigger_type,
triggering_event,
table_owner,
table_name,
base_object_type,
status,
trigger_body
FROM
all_triggers
ORDER BY
owner ASC,
trigger_name ASC,
base_object_type ASC,
table_name ASC;
This view includes an owner
column that tells us who the owner is, so I’ve included that in this query, and also sorted the results by that column.
The dba_triggers
View
The dba_triggers
view lists all triggers in the database:
SELECT
owner,
trigger_name,
trigger_type,
triggering_event,
table_owner,
table_name,
base_object_type,
status,
trigger_body
FROM
dba_triggers
ORDER BY
owner ASC,
trigger_name ASC,
base_object_type ASC,
table_name ASC;
This view’s columns are the same as those in the all_triggers
view.