Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 22nd, 2006, 11:34 PM
fuzzybunny's Avatar
fuzzybunny fuzzybunny is offline
C Neophyte.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Melbourne Australia
Posts: 332 fuzzybunny User rank is Sergeant (500 - 2000 Reputation Level)fuzzybunny User rank is Sergeant (500 - 2000 Reputation Level)fuzzybunny User rank is Sergeant (500 - 2000 Reputation Level)fuzzybunny User rank is Sergeant (500 - 2000 Reputation Level)fuzzybunny User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 12 h 15 m 3 sec
Reputation Power: 14
Talking Cascading Drop Table?

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.

SQL Code:
Original - SQL Code
  1. SELECT 'DROP TABLE '||Job||' CASCADE CONSTRAINTS;' FROM USER_TABLES;


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!

Reply With Quote
  #2  
Old August 23rd, 2006, 01:15 AM
bhushanm bhushanm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 32 bhushanm User rank is Private First Class (20 - 50 Reputation Level)bhushanm User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 2 m 6 sec
Reputation Power: 3
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')

Reply With Quote
  #3  
Old August 23rd, 2006, 02:23 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,043 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 6 h 52 m 33 sec
Reputation Power: 68
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Cascading Drop Table?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT