Find empty tables in PostgreSQL database

This query returns a list of all tables with no rows.


select n.nspname as table_schema,
       c.relname as table_name
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where c.relkind = 'r'
      and n.nspname not in ('information_schema','pg_catalog')
      and c.reltuples = 0
order by table_schema,


  • table_schema - table's schema name
  • table_name - table name


  • One row represents one table
  • Scope of rows: all tables without any rows
  • Ordered by schema and table name

Sample results

Empty tables in our pagila repository:

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