DBAtlas · Database operations atlas

ORA-02449: unique/primary keys in table referenced by foreign keys

Oracle

What does it mean?

The primary or unique key of the table you want to drop is referenced by foreign keys in other tables. Oracle does not let you drop the table without removing these dependencies first.

Why does it happen?

You ran DROP TABLE without CASCADE CONSTRAINTS while other tables reference this table through FKs. Enforcing referential integrity, Oracle prevents orphaned foreign keys.

How to fix it

To drop it together with the dependent foreign keys: DROP TABLE table_name CASCADE CONSTRAINTS; This also removes the related FK constraints in the other tables (it does not delete the data in those tables). To see which constraints depend on it: SELECT table_name, constraint_name FROM all_constraints WHERE r_constraint_name IN (SELECT constraint_name FROM user_constraints WHERE table_name = 'TABLE_NAME');

Open in DBAtlas →

More from this engine