如何查看MS PDW表的大小?

时间:2014-12-10 06:58:16

标签: sql-server

在我已知的MS SQLServer中检查表空间大小的方法是

sp_spaceused [tablename]

OR

SELECT 
    t.NAME AS TableName,
    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
WHERE 
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255
GROUP BY 
    t.Name, p.Rows
ORDER BY 
    t.Name

但我无法在MS PDW(SQL Server 2012并行数据仓库)中找到[sys]。[allocation_units]表。

因此很难检查表格大小。

我怎么知道表空间大小?

1 个答案:

答案 0 :(得分:0)

USE AdventureWorksPDW2012;
DBCC PDW_SHOWSPACEUSED ( "AdventureWorksPDW2012.dbo.FactInternetSales" );
DBCC PDW_SHOWSPACEUSED ( "AdventureWorksPDW2012..FactInternetSales" );
DBCC PDW_SHOWSPACEUSED ( "dbo.FactInternetSales" );
DBCC PDW_SHOWSPACEUSED ( FactInternetSales );