Skip to content

Instantly share code, notes, and snippets.

@jishanshaikh4
Created June 15, 2022 03:08
Show Gist options
  • Save jishanshaikh4/8726c7b98754dbb3de3f5eefccb79b7e to your computer and use it in GitHub Desktop.
Save jishanshaikh4/8726c7b98754dbb3de3f5eefccb79b7e to your computer and use it in GitHub Desktop.
Find empty tables in MySQL server
select
t.name table_name
from
sys.tables t
join sys.schemas s on (t.schema_id = s.schema_id)
join sys.partitions p on (t.object_id = p.object_id)
where p.index_id in (0, 1)
group by t.name,s.name
having sum(p.rows) = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment