Home » SQL & PL/SQL » SQL & PL/SQL » deleting all tables
deleting all tables [message #2234] Mon, 01 July 2002 06:40 Go to next message
sree hari
Messages: 10
Registered: July 2002
Junior Member
Hi,
can anyone give me solution for the below

how to delete all table once in a perticular user

thanking you
sree hari
Re: deleting all tables [message #2238 is a reply to message #2234] Mon, 01 July 2002 07:00 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
u can use this script.
You need to login as dba user else,
change the script ( instead of dba_tables, use user_tables).
if you are looking for droping the tables, then
chnage the script to
str:='drop table '||mag.owner||'.'||mag.table_name;

SQL> get del
  1  DECLARE
  2  cursor  c1 is select table_name,owner from dba_tables where
  3     owner=upper('&username');
  4   Str varchar2(100);
  5   begin
  6   for mag in c1 loop
  7   exit when c1%notfound;
  8   str:='delete from  '||mag.owner||'.'||mag.table_name;
  9   execute immediate str;
 10   end loop;
 11* end;
Re: deleting all tables [message #2250 is a reply to message #2234] Tue, 02 July 2002 01:37 Go to previous message
Amit
Messages: 166
Registered: February 1999
Senior Member
you can do this ...

SELECT 'drop TABLE ' || tname || ' CASCADE CONSTRAINTS' from tab;

Spool d:drop_user_tables.sql
SELECT 'Drop TABLE ' || tname || ' CASCADE CONSTRAINTS' from tab;
select 'Drop VIEW ' || view_name from user_views;
select 'Drop TRIGGER ' || TRIGGER_NAME from user_triggers;
Spool off
@d:drop_user_tables.sql
Previous Topic: URGENT: ORA-04091 table name is mutating, trigger/function may not see it
Next Topic: Returning PL/SQL exit code to a korn shell script
Goto Forum:
  


Current Time: Thu May 09 04:39:48 CDT 2024