943,747 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 6451
  • Oracle RSS
Mar 31st, 2007
0

deleting the tables

Expand Post »
how to delete all the tables in the a user at a time?
Similar Threads
Reputation Points: 9
Solved Threads: 1
Light Poster
satish.paluvai is offline Offline
45 posts
since Mar 2007
Mar 31st, 2007
0

Re: deleting the tables

There is no one command to do this, you could write a PL procedure to do it, or generate the SQL statements from USER_TABLES. Alternately some IDE's provide an easier way.
Reputation Points: 12
Solved Threads: 8
Junior Poster
davidcairns is offline Offline
114 posts
since Feb 2007
Apr 12th, 2007
0

Re: deleting the tables

if in yor databse you have only tables then simply can drop user
or u can create one one store procedure to delete all table from your databse
Reputation Points: 10
Solved Threads: 1
Newbie Poster
wavalker is offline Offline
11 posts
since Apr 2007
Jul 14th, 2007
0

Re: deleting the tables

try to write a script for this
or
a better option would be to write a cursor and then drop the tables .
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Aug 23rd, 2007
0

Re: deleting the tables

You have two options:
---------------------------------------
1) Create a script
set lines 200;
set pages 10000;
spool c:\DROP_TABLES.txt;
select 'DROP TABLE '||table_name||';'
from all_tables
where owner = 'SCOTT';
-- change the SCOTT to the owner of the tables you need to drop.
spool off;
---------------------------------------
@c:\DROP_TABLES.txt; -- to run the script that we created.
-- repeat this step tell u drop all the tables.
---------------------------------------

2) From the Enterprise Manager , Drop the owner Schema.

Regards.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Musta is offline Offline
6 posts
since Aug 2007
Mar 13th, 2009
0

Re: deleting the tables

Oracle Syntax (Toggle Plain Text)
  1. BEGIN
  2. FOR c IN (SELECT table_name FROM user_tables) LOOP
  3. EXECUTE IMMEDIATE ('drop table '||c.table_name||' cascade constraints);
  4. end loop;
  5. End;
  6.  

Best regard,
<URL SNIPPED>Fellow Developer
---------------------------------------------------------------------
Visit URL: <URL SNIPPED>
Last edited by peter_budo; Mar 18th, 2009 at 7:33 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bala4901 is offline Offline
1 posts
since Jul 2008
Jan 6th, 2011
0
Re: deleting the tables
Oracle Syntax (Toggle Plain Text)
  1. DECLARE
  2. table_name VARCHAR2(30);
  3. CURSOR usertables IS SELECT * FROM user_tables WHERE table_name NOT LIKE 'BIN$%';
  4. BEGIN
  5. FOR next_row IN usertables
  6. LOOP
  7. EXECUTE IMMEDIATE 'drop table ' || next_row.table_name || ' cascade constraints';
  8. END LOOP;
  9. END;

save it as a .sql file and run it from oracle sql plus using this command @path\filename.SQL / will remove all tables from USER_TABLES (where all the user tables are created ) in the current schema pointed to SQL PLUS

Regards
VIJINDAS
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vijin is offline Offline
1 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: Inserting a new column!!!!!!!!
Next Thread in Oracle Forum Timeline: oracle 11i





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC