How To: Disable All Foreign Keys in Oracle Scheme

When you perform data maintenance operations, sometimes, it’s necessary to disable or enable all foreign keys in the user schema.

Here is the script that solves this task:

Executing the script with the ON_OFF parameter set to ‘OFF’ will lead to disabling foreign keys, and setting it to ‘ON’ will lead to enabling them.

But you should keep in mind that if data after synchronization contradicts the logic of data integrity on the server side the procedure of disabling and enabling foreign keys will fail.

You can also use this script in express edition of dbForge Data Compare for Oracle when transferring master-detail data.

Leave a Comment