Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: [Question]drop all tables owned by a user
anonymous wrote:
>
> Is it possible to drop all tables by user who owns those tables in one
> sqlstatement? for instance, I have a user who has A, B, C ... Z
> tables.
> Then I want to drop all those tables by sql statement. is it possible?
> If yes, how?
> I appreciate any suggestion, sincerely.
begin
for i in ( select table_name from user_tables ) loop
execute immediate 'drop table '||i.table_name||' cascade
constraints';
end loop
end;
/
-- Connor McDonald Co-author: "Mastering Oracle PL/SQL - Practical Solutions" Co-author: "Oracle Insight - Tales of the OakTable" web: http://www.oracledba.co.uk web: http://www.oaktable.net email: connor_mcdonald_at_yahoo.com "GIVE a man a fish and he will eat for a day. But TEACH him how to fish, and...he will sit in a boat and drink beer all day" ------------------------------------------------------------Received on Wed Jan 26 2005 - 08:02:57 CST