Friday 2 November 2012

MySQL:List of non-empty tables in mysql database


List of non-empty tables in mysql database


Use database 'information_schema' and run
SELECT * FROM `TABLES` WHERE `TABLE_ROWS` > 0 
this will give you all non-empty tables in the server for a certain database run
SELECT * FROM `TABLES` WHERE `TABLE_ROWS` > 0  AND `TABLE_SCHEMA` = 'database_name'

To select from a selective database, you can filter by column TABLE_SCHEMA
select table_schema, table_type, table_name 
from information_schema.tables where table_rows>=1;

No comments:

Post a Comment