Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Remove all tables for user with one SQl statement?

Re: Remove all tables for user with one SQl statement?

From: <sybrandb_at_yahoo.com>
Date: 19 Dec 2005 01:21:05 -0800
Message-ID: <1134984064.979927.304800@g44g2000cwa.googlegroups.com>

Jan Doggen wrote:
> Hi
>
> How can I remove all tables
> UserName.TblNam1
> UserName.TblNam2
> UserName.TblNam3
> etc
>
> with one SQL statement?
>
> Dropping the user is not allowed.
>
> Thanks in advance
> Jan

You can't.
You can of course
begin
for tab in (select table_name from dba_tables where owner= 'UserName' ) loop
execute immediate 'drop table Username.'||tab.table_name||' cascade constraints';
end loop;
end;
/
But you would need to make sure there are no foreign keys or drop the tables in the right order.
Maybe you are disallowed to drop the user for a reason, and you would better not allowed to drop tables too.

-- 
Sybrand Bakker
Senior Oracle DBA
Received on Mon Dec 19 2005 - 03:21:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US