计算数据库中所有表的记录数并输出.sql
适用于MySQL5.0以上版本。1、构造SQL语句
sql>use information_schema;
sql>select concat("select """, TABLE_name,""", count(*) from ", TABLE_name," union all") from tables where TABLE_SCHEMA='huashan';
2、执行后输出:
select "BackUpinfo", count(*) from BackUpinfo union all
select "CustomQuery", count(*) from CustomQuery union all
select "DATA_SOURCE", count(*) from DATA_SOURCE union all
select "DBTableList", count(*) from DBTableList union all
select "DBTableType", count(*) from DBTableType union all
select "DEVICE", count(*) from DEVICE union all
......
3、结果:
...... 赞!
mysql 4.1中无information_schema表。
mysql> use information_schema;
ERROR 1049 (42000): Unknown database 'information_schema'
还有其他办法吗? 目前没有 :victory: nice
页:
[1]