【发布时间】:2021-07-31 17:03:54
【问题描述】:
网络上的某个地方(缺少源,可能在这里)我得到了这个 SQL 语句:
SELECT t.NAME AS TableName, SUM(a.total_pages) * 8 AS TotalSpaceKB, p.Rows FROM sys.tables t
INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id
WHERE t.NAME NOT LIKE 'dt%' AND t.NAME LIKE '%MY_TABLES%' AND s.Name LIKE 'MY_ACHEMA'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY t.Name, p.Rows
ORDER BY p.Rows DESC
这给了我一个美丽的景色,有 3 列。像这样:
TableName TotalSpaceKB Rows
TABLE 3231656 76000
TABLE 2305632 29136
TABLE 2213128 14160
TABLE 1954200 3020
etc...
现在我想扩展它以包括每个表的列数。如何做到这一点?
【问题讨论】:
-
用您正在使用的数据库标记您的问题。
标签: sql size dimensions