Find empty tables in Db2 database

This query returns list of tables in a database without any rows.

Query

select tabschema || '.' || tabname as table
from syscat.tables
where card = 0
      and tabschema not like 'SYS%'
order by table;

Columns

  • table - table name with schema name

Rows

  • One row represents one table
  • Scope of rows: only empty tables (without rows)
  • Ordered by schema and table name

Notes

Number of rows may be not up to date as it's taken from DB2 statistics. Statistics must be updated after tables has had many updates, or after reorganizing any of the tables. You can do it with RUNSTATS command.

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.