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

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

SV: Empty Table

From: Jesper Haure Norrevang <jhn.aida_at_cbs.dk>
Date: Mon, 24 Jan 2005 14:05:54 +0100
Message-id: <000101c50215$6fe89750$4a28e282@AIDA.local>


Jacinta,

> I need some help here. I need to get a report of all
> the table that are empty on a schema.

A quick way to determine whether a table is empty, regardless whether there are milions of rows in the table or not:

select count(*) from some_table where rownum < 2;

I have played a little with SQL*Plus. It is not nice, but it works.

set lines 132
set heading off
set pages 0
set feedback off
spool work.sql
select
  'select ''' || table_name || ''' from ' || table_name ||   ' where rownum < 2 having count(*) > 0;' from
  user_tables
order by table_name
;
spool off
spool empty_tables.log
@work.sql
spool off
exit

Regards
Jesper Haure Norrevang

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jan 24 2005 - 08:08:28 CST

Original text of this message

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