|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I'm nearly to the end of my assignment! I've got it working, but I was shown this at a lecture, and I'm not sure what it means.
It's meant to drop all tables by dropping the first table, then dropping its dependancy, etc until all gone, yes? 1 - Can't seem to get it to work... syntax problem? 2 - Do I point it at the 'head' or the 'tail'? (independent or dependent?) I suspect point it to the dependant table? 3 - Any background on how this query actually works? I'd google it but the query looks very specific! Thanks for any help! |
|
#2
|
|||
|
|||
|
try this...
SELECT 'DROP TABLE '||table_name||' CASCADE CONSTRAINTS;' FROM USER_TABLES This query does not drop the tables by itself, but generates queries to do the same. these queries then need to be run in order to drop the tables. You can restrict which tables to drop by selecting specific tables : SELECT 'DROP TABLE '||table_name||' CASCADE CONSTRAINTS;' FROM USER_TABLES where table_name in ('EMP','DEPT') |
|
#3
|
|||
|
|||
|
And additionally: CASCADE CONSTRAINTS simply means that any FK constraint referencing other tables is also dropped, it does not mean the referenced tables will be dropped.
Of course if you run the generated script then all tables will be gone as a result of that, but this is not caused by the CASCADE CONSTRAINT option |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Cascading Drop Table? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|