獲取資料庫空閒空間的SQL
created by Tom Kyte.
Tablespace Name : name of tablespace, leading '*' indicates a good locally managed tablespace, leading blank means it is a bad dictionary managed tablespace. Second character of A implies ASSM managed storage, second character of M implies manually managed (pctused, freelists, etc are used to control space utilization)
Kbytes : allocated space of the tablespace, sum of kbytes consumed by all datafiles associated with tablespace.
Used : space in the tablespace that is used by some segment.
Free : space in the tablespace not allocated to any segment.
%Used : ratio of free to allocated space
largest : mostly useful with dictionary managed tablespaces, the size of the largest contigously set of blocks available. If this number in a dictionary managed tablespace is smaller than the next extent for some object, that object could fail with "out of space" even if the FREE column says there is lots of free space.
MaxPoss Kbytes: the autoextend max size (note CAN be smaller than the allocated size!!!! you can set the maxsize to be less than the current size of a file)
%Max Used : how much of the maximum autoextend size has been used so far
set linesize 200
-------------------------------------------------------
-- free.sql
--
-- This SQL Plus script lists freespace by tablespace
--------------------------------------------------------
column dummy noprint
column pct_used format 999.9 heading "%|Used"
column name format a19 heading "Tablespace Name"
column Kbytes format 999,999,999 heading "KBytes"
column used format 999,999,999 heading "Used"
column free format 999,999,999 heading "Free"
column largest format 999,999,999 heading "Largest"
column max_size format 999,999,999 heading "MaxPoss|Kbytes"
column pct_max_used format 999.9 heading "%|Max|Used"
break on report
compute sum of kbytes on report
compute sum of free on report
compute sum of used on report
select (select decode(extent_management,'LOCAL','*',' ') ||
decode(segment_space_management,'AUTO','a ','m ')
from dba_tablespaces where tablespace_name = b.tablespace_name) ||
nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/
kbytes_alloc)*100 pct_used,
nvl(largest,0) largest,
nvl(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from ( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_data_files
group by tablespace_name
union all
select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_temp_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by &1
/
8i或以下版本:
column dummy noprint
column pct_used format 999.9 heading "%|Used"
column name format a19 heading "Tablespace Name"
column Kbytes format 999,999,999 heading "KBytes"
column used format 999,999,999 heading "Used"
column free format 999,999,999 heading "Free"
column largest format 999,999,999 heading "Largest"
column max_size format 999,999,999 heading "MaxPoss|Kbytes"
column pct_max_used format 999.9 heading "%|Max|Used"
break on report
compute sum of kbytes on report
compute sum of free on report
compute sum of used on report
select (select decode(extent_management,'LOCAL','*',' ')
from dba_tablespaces where tablespace_name = b.tablespace_name) ||
nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/
kbytes_alloc)*100 pct_used,
nvl(largest,0) largest,
nvl(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from ( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_data_files
group by tablespace_name
union all
select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_temp_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by &1
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/6906/viewspace-21766/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 獲取表空間DDL
- 清理oracle資料庫空間Oracle資料庫
- 【資料庫資料恢復】SQL Server資料庫磁碟空間不足的資料恢復案例資料庫資料恢復SQLServer
- 【TUNE_ORACLE】檢視Oracle的壞塊在空閒空間中還是在已用空間中的SQL參考OracleSQL
- PostgreSQL:表空間-->資料庫-->表SQL資料庫
- 如何獲取 PostgreSQL 資料庫中的表大小、資料庫大小、索引大小、模式大小、表空間大小、列大小SQL資料庫索引模式
- PHP 獲取伺服器磁碟空間PHP伺服器
- 達夢資料庫表空間等空間大小查詢方法總結資料庫
- SciPy 空間資料
- Runloop有效利用空閒時間OOP
- 【資料庫資料恢復】磁碟空間不足導致sql server錯誤的資料恢復資料庫資料恢復SQLServer
- 時間和空間的完美統一!阿里雲時空資料庫正式商業化阿里資料庫
- oracle dg庫資料檔案空間不足Oracle
- Oracle資料庫閃回區空間不足Oracle資料庫
- PHP 獲取不帶名稱空間的類名PHP
- 檢視資料庫佔用磁碟空間的方法資料庫
- SQLServer行版本資訊吃資料庫tempdb空間SQLServer資料庫
- DB2建立資料庫,建立表空間DB2資料庫
- 資料分析軟體Power BI探索資料教程(六)——如何獲取更多儀表盤空間
- 虛擬主機資料庫與空間關係資料庫
- ASM空間爆滿導致資料庫掛起ASM資料庫
- 空間劃分的資料結構資料結構
- python批量統計Oracle資料庫的空間使用量PythonOracle資料庫
- 資料技術大融合,HSTAP資料庫有多少想象空間?資料庫
- oracle建立臨時表空間和資料表空間以及刪除Oracle
- 2.5.9 在資料庫建立期間支援大檔案表空間資料庫
- GBase8s 檢視資料庫表空間資訊資料庫
- PostgreSQL-表空間、資料庫、使用者之間的關係(七)SQL資料庫
- OracleDatabase——資料庫表空間dmp匯出與匯入OracleDatabase資料庫
- 乾貨分享|優炫資料庫管理之表空間資料庫
- (資料科學學習手札84)基於geopandas的空間資料分析——空間計算篇(上)資料科學
- (資料科學學習手札88)基於geopandas的空間資料分析——空間計算篇(下)資料科學
- oracle sql 表空間利用率OracleSQL
- GeoRapter工具將shapefile資料匯入到Oracle空間資料庫中APTOracle資料庫
- 資料庫恢復中需要大量儲存空間的原因HQ資料庫
- 表空間和資料檔案的管理
- Oracle案例11——Oracle表空間資料庫檔案收縮Oracle資料庫
- 資料庫系統 空值 null資料庫Null
- 16、表空間 建立表空間