首頁 >資料庫 >mysql教程 >SQL Server 计算表记录数、当前自增值和占用空间

SQL Server 计算表记录数、当前自增值和占用空间

WBOY
WBOY原創
2016-06-07 14:56:381527瀏覽

SQL Server 计算表记录数、当前自增值和占用空间 无 SELECTTableName = obj.name,TotalRows = prt.rows,Identity_Current=IDENT_CURRENT(obj.name),[SpaceUsed(KB)] = SUM(alloc.used_pages)*8FROM sys.objects objJOIN sys.indexes idx on obj.object_id = i

SQL Server 计算表记录数、当前自增值和占用空间
SELECT
TableName = obj.name,
TotalRows = prt.rows,Identity_Current=IDENT_CURRENT(obj.name),
[SpaceUsed(KB)] = SUM(alloc.used_pages)*8
FROM sys.objects obj
JOIN sys.indexes idx on obj.object_id = idx.object_id
JOIN sys.partitions prt on obj.object_id = prt.object_id
JOIN sys.allocation_units alloc on alloc.container_id = prt.partition_id
WHERE
obj.type = 'U' AND idx.index_id IN (0, 1)
GROUP BY obj.name, prt.rows
ORDER BY TableName
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn