Re: truncate tables in my tablespace

From: Frank van Bortel <>
Date: Fri, 18 Jan 2008 10:03:19 +0100
Message-ID: <bc72c$47906b57$524b5c40$>

loosethisskin wrote:

> On Jan 17, 1:50 pm, wrote:

>> Hello,
>> I want to delete all the data in all the tables in my tablespace.
>> SQL> select table_name from user_tables;
>> I can get a list of the tables but I dont want to a
>> for each table type in
>> SQL> delete from tablename;
>> Is there a smart way of doing this?
>> TIA
>> J
> begin
>   for t in (select table_name from user_tables)
>   loop
>     execute immediate('truncate table ' || t.table_name);
>   end loop;
> end;
> /

As Arun indicated, you'll have to disable constraints. Better add an exception handler to the code above to silently continue when failing.

Frank van Bortel

Top-posting in UseNet newsgroups is one way to shut me up
Received on Fri Jan 18 2008 - 03:03:19 CST

Original text of this message