Created
February 20, 2024 19:20
-
-
Save cnnrrss/ff683ca10cfb4845b1a20f125c724e41 to your computer and use it in GitHub Desktop.
Find empty tables in Postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
t.tablename | |
FROM | |
pg_catalog.pg_tables t | |
LEFT JOIN pg_stat_user_tables stat ON t.tablename = stat.relname | |
WHERE | |
t.schemaname = 'public' -- Adjust this to your schema name if different | |
AND stat.n_live_tup = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment