Created
June 15, 2022 03:08
-
-
Save jishanshaikh4/8726c7b98754dbb3de3f5eefccb79b7e to your computer and use it in GitHub Desktop.
Find empty tables in MySQL server
This file contains hidden or 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.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