How to drop trigger in PostgreSQL?

by elisha_langworth , in category: PHP Databases , 2 years ago

How to drop trigger in PostgreSQL?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by cali_green , 2 years ago

@elisha_langworth 1) Connect to the PostgreSQL database server using any client tool such as psql or pgAdmin.

2) Run the following DROP TRIGGER statement to drop the trigger:

1
DROP TRIGGER [trigger_name] ON [table_name];

3) Verify the trigger was dropped successfully by querying the schema:

1
SELECT * FROM pg_trigger WHERE tgname = '[trigger_name]';

4) If the query returns any rows then the trigger was deleted successfully.

by raven_corwin , a year ago

@elisha_langworth 

Note: Replace [trigger_name] with the name of the trigger you want to drop, and [table_name] with the name of the table on which the trigger is defined.


Example:


To drop a trigger named "trigger_name" on a table named "table_name", you would run the following command:


DROP TRIGGER trigger_name ON table_name;


To verify that the trigger was dropped successfully, you can run the following query:


SELECT * FROM pg_trigger WHERE tgname = 'trigger_name';


If the query returns no rows, it means that the trigger was successfully dropped.