Dropping Oracle tables referenced by foreign keys

I just wanted to quickly clear out some tables from a database and was having problems dropping some of them. I was receiving errors like these:

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

and

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

After a quick google, I discovered that you can add the "cascade constraints" suffix to drop the tables and associated constraints. Simply do:

drop table table_name cascade constraints;

Works a treat and a great tip to remember and use in future.

Advertisements
This entry was posted in Computers and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s