2012-04-05 81 views
7

我試圖將SQL Anywhere 11SQL Anywhere的11 - 表大小

我只是發現了sp_spaceused已棄用

任何幫助,這將得到一個數據庫中的每個表的表大小不勝感激! :)

+0

你有一個鏈接,確認它的折舊或者是這種猜測? – 2012-04-05 20:28:15

+0

找到了。 http://dcx.sybase.com/1001/en/dbwnen10/wn-newjasper-s-3751424.html – 2012-04-05 20:30:14

+0

有沒有這方面的運氣? – tray 2012-04-05 22:28:22

回答

4

系統視圖SYSTAB可能是一個很好的選擇。它可以爲您提供表格中的行數,並且可以爲您提供表格使用的頁數。 (在下面的示例,我乘的由數據庫的頁面大小的頁面數得到一個總字節數。)

SELECT 
    count,      -- number of rows in the table 
    (table_page_count * DB_PROPERTY('PageSize')) tablesize 
           -- total size, in bytes 
FROM SYSTAB 
WHERE table_name = 'mytable'; -- or whatever limitations you want on 
           -- the scope of the query 

希望這有助於。

1

您可以使用SQL Server此腳本來查找數據庫和行中最大的表計

SELECT sc.name +'.'+ ta.name TableName 
,SUM(pa.rows) RowCnt 
FROM sys.tables ta 
INNER JOIN sys.partitions pa 
ON pa.OBJECT_ID = ta.OBJECT_ID 
INNER JOIN sys.schemas sc 
ON ta.schema_id = sc.schema_id 
WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0) 
GROUP BY sc.name,ta.name 
ORDER BY SUM(pa.rows) DESC