回答
這應該適合你工作因爲它適合我。 How to find the total tablespace usage in SQL Server 2008?通過奧列格的Dok
set nocount on
declare @indexes table(
QualifiedName nvarchar(512),
IndexId int,
FGName nvarchar(128),
Type nvarchar(50),
NumKeys int,
IndexKB numeric(28,0),
UsedKB numeric(28,0),
FreeKB numeric(28,0),
Rows numeric(28,0),
RowModCtr numeric(28,0),
OrigFillFactor int,
tableid bigint
)
insert into @indexes
select
db_name() + '.' + isnull(su.name,'<unknown-user>') + '.' + so.name + '.' + isnull(i.name,'<Heap>') QualifiedName,
i.index_id IndexId,
(select isnull(name,'') from sys.filegroups where data_space_id = i.data_space_id) FGName,
case
when so.type = 'V' then 'Indexed View: '
else ''
end +
case
when i.index_id = 0 then 'Heap'
when i.index_id = 1 then 'Clustered'
else 'Non Clustered'
end Type,
0 NumKeys,
a.used_pages* 8 IndexKB,
CASE
When a.type <> 1 Then a.used_pages * 8
When p.index_id < 2 Then a.data_pages * 8
Else 0
END UsedKB,
(a.total_pages-a.used_pages)* 8 FreeKB,
p.rows Rows,
0 RowModCtr,
i.fill_factor OrigFillFactor,
convert(bigint,db_id()) * power(convert(bigint,2),48) + convert(bigint,su.schema_id) * power(convert(bigint,2),32) + so.object_id tableid
from
sys.objects so with (readpast)
inner join sys.schemas su with (readpast) on su.schema_id = so.schema_id
inner join sys.indexes i with (readpast) on so.object_id = i.object_id
inner join sys.partitions p with (readpast) ON i.object_id = p.object_id and i.index_id = p.index_id
inner join sys.allocation_units a with (readpast) on p.partition_id = a.container_id
where
(so.type = 'U') and a.type_Desc = 'IN_ROW_DATA'
and isnull(INDEXPROPERTY(i.object_id, i.name, 'IsStatistics'),0) = 0
and isnull(INDEXPROPERTY(i.object_id, i.name, 'IsAutoStatistics'),0) = 0
and isnull(INDEXPROPERTY(i.object_id, i.name, 'IsHypothetical'),0) = 0
order by
IndexKB desc
select
i.QualifiedName,
i.IndexId,
i.FGName,
i.Type,
i.NumKeys,
i.IndexKB,
(i.UsedKB - isnull(t.s_UsedKB,0)) UsedKB,
(i.FreeKB - isnull(t.s_FreeKB,0)) FreeKB,
i.Rows,
i.RowModCtr,
i.OrigFillFactor
from
@indexes i
left outer join (
select tableid, sum(UsedKB) s_UsedKB, sum(FreeKB) s_FreeKB
from @indexes
where IndexId > 1
group by tableid
) t on t.tableid = i.tableid
and i.IndexId <= 1
order by
IndexKB desc
的最佳方式你好oshopath。感謝您的幫助。 但我發現了錯誤.. ORA-06550:第1行,第9欄: PLS-00103:出現符號「@」期待之一時執行以下操作: 開始功能編譯程序亞型類型<標識符> 當前光標刪除 先前存在 06550. 00000 - 「行%s,列%s:\ n%s」 *原因:通常是PL/SQL編譯錯誤。 *操作: 可能是什麼原因 – 2014-10-30 05:57:01
這是因爲此解決方案適用於SQL Server,而您正嘗試在Oracle中使用它。 – 2014-10-30 07:38:36
好的。那麼如何在Oracle中做到這一點? – 2014-10-30 09:25:44
在Oracle表空間名稱被包含在DBA_TABLES視圖:
解從refered。
select owner, tablespace_name
from dba_tables
where table_name = 'MyTableName'
或者您可以使用USER_TABLES視圖以查看錶名和當前架構只包含表的TS名。
select table_name, tablespace_name
from user_tables
where table_name = 'MyTableName'
- 1. Sql Server空間在oracle中查找最近鄰居
- 2. Oracle:如何查找表空間碎片?
- 3. 如何查找和刪除sql server中列值的空間
- 4. 如何在oracle 11g的特定表空間中查找用戶?
- 5. SQL Server空間查找剩餘距離
- 6. 在oracle中查找空教室sql
- 7. 如何從SQL Server 2000查詢Oracle表?
- 8. 如何查找SQL Server 2008中的總表空間使用情況?
- 9. 列表(在DB2,SQL Server,Informix和Oracle中)
- 10. NHibernate,Oracle和表空間
- 11. 如何在SQL Server中查找數字序列中的空白
- 12. 如何在Oracle的每個表空間中查找最大表格
- 13. 如何在Oracle和SQL Server之間進行兼容的SQL查詢?
- 14. 如何查找上次在oracle中查詢表的時間
- 15. 如何找出SQL Server表使用多少空間?
- 16. SQL Server 2008查找時間
- 17. Oracle:如何找到在表空間中減少可用空間的原因?
- 18. oracle和sql server
- 19. 如何查找在SQL Server 2008中創建表的查詢
- 20. SQL-Server和Oracle - 爲了在子查詢
- 21. 如何在SQL Server中查找日期間的差距?
- 22. 如何解決在SQL Server空間
- 23. 如何在Sql Server 2005中查找更新到表中的行的時間?
- 24. 如何在SQL Server Management Studio中獲取表的空間參考?
- 25. SQL Server和Oracle中的比較表
- 26. 如何在Oracle,SQL Server和ASP.NET之間實現哈希
- 27. 如何在SQL Server中的目標表中查找新字段?
- 28. 在SQL Server中查找行
- 29. 查找在SQL Server
- 30. 查找MAX值的時間在SQL Server
這裏是要做到這一點,請參考以下鏈接http://www.mssqltips.com/sqlservertip/2393/determine-sql-server-memory-use-by-database-and-object/ – 2014-10-30 05:26:44