如何检查用户定义数据库的表大小
答案 0 :(得分:1)
试试这个,sp_spaceused'Your_tableName'
答案 1 :(得分:0)
如果您使用的是SQL Server Management Studio,则可以通过打开对象资源管理器详细信息(按F7)进行检查。然后单击Tables文件夹并从表列表中找到您的表。单击表后,您将找到使用的数据空间和以千字节为单位的索引空间。 如果您想要检查尺寸的正确说明,可以参考 https://dba.stackexchange.com/questions/81245/how-to-determine-the-size-of-my-tables-in-the-sql-server-database/81253
答案 2 :(得分:0)
试试这个
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
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.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, s.Name, p.Rows
ORDER BY
t.Name