MySQL query all the table names containing the data record in a database

MySQL query all the table names containing the data record in a database


 

Sometimes depending on the application, the need for data backup.

Those data table if there are a lot of data in a database table, but just want to back up the data records (data not backed up empty table).

If by SQL, one by one to confirm whether there is data in the table, it is inefficient:

select count(1) from tableN;

 

How direct access to a database of all the table names that contain data it?


 

 

SQL query as follows:

SELECT TABLE_NAME 
 from information_schema.tables 
 WHERE the TABLE_SCHEMA =  ' database name to be queried '  and TABLE_ROWS >  0 ;

 

 

 

 

Guess you like

Origin www.cnblogs.com/miracle-luna/p/12059291.html