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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Empty Table

Re: Empty Table

From: Mladen Gogala <gogala_at_sbcglobal.net>
Date: Mon, 24 Jan 2005 05:52:47 +0000
Message-Id: <1106545967l.28754l.0l@medo.noip.com>

On 01/24/2005 12:35:08 AM, J.Velikanovs_at_alise.lv wrote:
> I think he most effective way to archive your coal is something like:
>=20
> declare
> rid rowid;
> v_fname varchar2(60);
> begin
> for v_tab in (select table_name from user_tables) loop
> v_fname:=3Duser||'.'||v_tab.table_name;
> execute immediate 'select rowid from '||v_fname||' where rownum=3D1'
> into
> rid;
> end loop;
> exception
> when
> no_data_found
> then dbms_output.put_line(v_fname||' is empty');
> end;
> /
>

Oh, I can do one better. Here is a little script that will very quickly find all tables empty in a given schema.

declare
cmd varchar2(128):=3D'truncate table ';
cursor csr is select table_name from user_tables; begin
for c in csr loop
  execute immediate cmd||c.table_name;
end loop;
dbms_output.put_line('All tables are empty!'); end;
/
--=20
Mladen Gogala
Oracle DBA

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jan 24 2005 - 00:55:16 CST

Original text of this message

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