How to disable foreign key constraint in postgresql

Generally in PostgreSQL, when you create a foreign key on a table, internally a trigger is created to check data integrity. PostGreSQL does not any direct feature to enable or disable the trigger to make foriegn key constraint disable.

In this article let’s discuss about how to disable foreign key constraint in postgresql. Let’s go through the following methods without any delay 🙂

Disable the trigger using following query.

ALTER TABLE my_table DISABLE TRIGGER ALL;

Once you did with your task, you can enable the trigger the same way as below

ALTER TABLE my_table ENABLE TRIGGER ALL;

Method 2 :

hi how areyou 

Hope the above methods works for you. Happy Learning and get back to us Anytime.

Realted Posts : Clear screen pascal