Search code examples
sql-query-store

How can i find list of all the table in database with contain atlease one record on it. which means have some data in tables.


i would like help with sql query which can find list of all table in a database which contain some data in it. just list of table with data excluding all the tables with no data on it .


Solution

  • In MySQL you can query the "information schema", however the numbers are only estimates, see https://dev.mysql.com/doc/refman/8.0/en/tables-table.html.

    SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_ROWS > 0 OR DATA_LENGTH > 0