如何用SQL语句查询表名和行数?
如何用SQL语句查询表名和行数?
Rudy Limeback: 是的,这相当简单。 select 'Customers' as tablename , count(*) as row_count from Customers union all select 'Orders' as tablename , count(*) as row_count from Orders union all select 'Products' as tablename , count(*) as row_count from Products union all 。
。。 如果你需要在你的数据库里的所有表上做这个查询,考试#大提示可以从INFORMATION_SCHEMA。TABLES视图生成表清单: select table_name from information_schema。tables where table_schema = 'mydatabase' 然后你可以利用这个查询的结果集和一个文本编辑器生成第一个查询。
答:虫虫学长,个人认为,一个SQL语句是不可能实现你的要求的。 你可以考虑自个写一个存储过程,在里面写一个游标,将count(*)等于0的表名插到临时表里,然后再S...详情>>