I'm writing a generic drop-all-objects script for our Oracle databases. It generates drop table TABLE_NAME cascade constraints purge
lines for all tables, amongst other object types, by looping through user_objects
.
The problem is that tables which are have reference-partitioned tables dependent on them can't be dropped in this way: ORA-14656: cannot drop the parent of a reference-partitioned table
.
How can I detect which tables are the parents of reference partitioned tables from the data dictionary, so I can skip them in the first loop, and drop them in a second loop?
Best Answer
To get a list of partitioned tables that have at least one referencing partitioned child table the
[dba][all][user]_part_tables
and[dba][all][user]_constrains
data dictionary views, depending on the privileges granted, can be queried:The query:
Result: