How to list triggers in PostgreSQL database
Aug 06th, 2021,At some point, you may need to list triggers in your PostgreSQL database, how to do that? well, we will list down some ways to do that.
1. Using SQL Query
If you want to list down all triggers in your PostgreSQL database. You can use the following SQL query:
SELECT event_object_table AS table_name ,trigger_name FROM information_schema.triggers GROUP BY table_name , trigger_name ORDER BY table_name ,trigger_name
Sample results
The above query will list all the triggers in your database:
If you are looking to list all triggers for a particular table, you need to specify the table name as follow:
SELECT event_object_table AS table_name ,trigger_name FROM information_schema.triggers WHERE event_object_table ='your_table_name' GROUP BY table_name , trigger_name ORDER BY table_name ,trigger_name
Result of the query for a specific table
2. Using psql
To list down triggers on a specific table using psql command-line, you can use the following command: \dS [your_table_name].
3. Using ERBuilder Data Modeler
ERBuilder Data Modeler offers you the possibility to list all triggers on tables in your database with just a few clicks away.
For more details about the trigger like the defining query you simply have to double-click on the trigger name. ERBuilder Data Modeler also gives you the possibility to edit the trigger.
How ERBuilder Helps
ERBuilder Data Modeler is a GUI data modeling tool that allows you to visualize, design and model databases by using entity relationship diagrams and automatically generates the most popular SQL databases including Amazon Redshift. Generate and share the data Model documentation with your team. Optimize your data model by using advanced features such as test data generation, schema compare and schema synchronization. Try now ERBuilder for 15 days FREE
Subscribe To Our Newsletter
Subscribe to our email newsletter today to receive updates of the latest news, tutorials and special offers!