查询SQLServer、MySql数据库中,某个数据库中的所有表的记录总数

时间:2022-08-11 08:26:47

SQLServer:

select a.name as 表名, max(b.rows) as 记录条数 from sysobjects as a, sysindexes as b
where
 a.id = b.id and a.xtype = 'u'
group
 by a.name
order by max(b.rows) desc;

或者

select a.name as 表名, b.rows as 记录条数 from sysobjects as a, sysindexes as b
where a.id = b.id and a.xtype='u' 

order by b.rows desc;

MySql:

select table_name, table_rows from `tables`
where TABLE_SCHEMA = 'infcn'
order by table_rows desc;