954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

deleting the tables

:?: how to delete all the tables in the a user at a time?

satish.paluvai
Light Poster
45 posts since Mar 2007
Reputation Points: 9
Solved Threads: 1
 

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.

davidcairns
Junior Poster
114 posts since Feb 2007
Reputation Points: 12
Solved Threads: 8
 

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

wavalker
Newbie Poster
11 posts since Apr 2007
Reputation Points: 10
Solved Threads: 1
 

try to write a script for this
or
a better option would be to write a cursor and then drop the tables .

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

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.

Musta
Newbie Poster
6 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 
Begin
for c in (select table_name from user_tables) loop
execute immediate ('drop table '||c.table_name||' cascade constraints);
end loop;
End;


Best regard,
Fellow Developer
---------------------------------------------------------------------
Visit URL:

bala4901
Newbie Poster
1 post since Jul 2008
Reputation Points: 10
Solved Threads: 0
 
DECLARE
	table_name VARCHAR2(30);
	   CURSOR usertables IS SELECT * FROM user_tables WHERE table_name NOT LIKE 'BIN$%';
	BEGIN
	   FOR next_row IN usertables
	   LOOP
	      EXECUTE IMMEDIATE 'drop table ' || next_row.table_name || ' cascade constraints';
	   END LOOP;
     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

vijin
Newbie Poster
1 post since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You