Microsoft SQL Server 显示当前数据库中所有表的大小
示例
SELECTs.name+ '.' +t.NAMEAS TableName,
SUM(a.used_pages)*8 AS 'TableSizeKB' --a page in SQL Server is 8kb
FROMsys.tablest
JOINsys.schemass ont.schema_id= s.schema_id
LEFT JOINsys.indexesi ONt.OBJECT_ID= i.object_id
LEFT JOINsys.partitionsp ONi.object_id=p.OBJECT_IDANDi.index_id= p.index_id
LEFT JOINsys.allocation_unitsa ONp.partition_id= a.container_id
GROUP BY
s.name, t.name
ORDER BY
--Either sort by name:
s.name+ '.' + t.NAME
--Or sort largest to smallest:
--SUM(a.used_pages) desc
以上是 Microsoft SQL Server 显示当前数据库中所有表的大小 的全部内容, 来源链接: utcz.com/z/337890.html