SET FOREIGN_KEY_CHECKS = 0; runs on a session basis . In the context of Oracle, I can only imagine that you need to do this when you have round links.
You commented that this is what you want to do:
SET FOREIGN_KEY_CHECKS = 0; DROP TABLE table1; DROP TABLE table2; SET FOREIGN_KEY_CHECKS = 1;
I assume that this means that TABLE1 has a foreign key referencing TABLE2, and TABLE2 has a foreign key referencing TABLE1.
If so, then Moudiz's answer is correct. You want to disable foreign keys before deleting the table:
alter table table1 disable constraint <constraint_name>; alter table table2 disable constraint <constraint_name>; drop table table1; drop table table2;
It makes no sense to disable all foreign keys for the duration of the session, you are only interested in two of them, both of which will be deleted using the table.
You do not want to disable all foreign keys.
The only other context I can think of is if you want to insert something into your circular link, in which case you will declare the constraint as DEFERRABLE. This means that the constraint check is performed at the end of the transaction, and not during DML, see the documentation .
If your links are not circular, just drop the tables in a different order.
source share