SQLServer
SELECT
SCHEMA_NAME(t.schema_id) AS SchemaName, -- 架构名
t.name AS TableName, -- 表名
SUM(p.rows) AS RowCounts -- 行数
FROM
sys.tables t
INNER JOIN
sys.partitions p ON t.object_id = p.object_id
WHERE
p.index_id IN (0, 1) -- 只考虑堆表(0)或聚集索引(1)
GROUP BY
t.schema_id, t.name
ORDER BY
RowCounts DESC;