表空間碎片檢測
======== Script. tfstsfgm ========
SET ECHO off REM NAME:TFSTSFRM.SQL REM USAGE:"@path/tfstsfgm" REM ------------------------------------------------------------------------ REM REQUIREMENTS: REM SELECT ON DBA_FREE_SPACE REM ------------------------------------------------------------------------ REM PURPOSE: REM The following is a script. that will determine how many extents REM of contiguous free space you have in Oracle as well as the REM total amount of free space you have in each tablespace. From REM these results you can detect how fragmented your tablespace is. REM REM The ideal situation is to have one large free extent in your REM tablespace. The more extents of free space there are in the REM tablespace, the more likely you will run into fragmentation REM problems. The size of the free extents is also very important. REM If you have a lot of small extents (too small for any next REM extent size) but the total bytes of free space is large, then REM you may want to consider defragmentation options. REM ------------------------------------------------------------------------ REM DISCLAIMER: REM This script. is provided for educational purposes only. It is NOT REM supported by Oracle World Wide Technical Support. REM The script. has been tested and appears to work as intended. REM You should always run new scripts on a test instance initially. REM ------------------------------------------------------------------------ REM Main text of script. follows: create table SPACE_TEMP ( TABLESPACE_NAME CHAR(30), CONTIGUOUS_BYTES NUMBER) / declare cursor query is select * from dba_free_space order by tablespace_name, block_id; this_row query%rowtype; previous_row query%rowtype; total number; begin open query; fetch query into this_row; previous_row := this_row; total := previous_row.bytes; loop fetch query into this_row; exit when query%notfound; if this_row.block_id = previous_row.block_id + previous_row.blocks then total := total + this_row.bytes; insert into SPACE_TEMP (tablespace_name) values (previous_row.tablespace_name); else insert into SPACE_TEMP values (previous_row.tablespace_name, total); total := this_row.bytes; end if; previous_row := this_row; end loop; insert into SPACE_TEMP values (previous_row.tablespace_name, total); end; . / set pagesize 60 set newpage 0 set echo off ttitle center 'Contiguous Extents Report' skip 3 break on "TABLESPACE NAME" skip page duplicate spool contig_free_space.lis rem column "CONTIGUOUS BYTES" format 999,999,999 column "COUNT" format 999 column "TOTAL BYTES" format 999,999,999 column "TODAY" noprint new_value new_today format a1 rem select TABLESPACE_NAME "TABLESPACE NAME", CONTIGUOUS_BYTES "CONTIGUOUS BYTES" from SPACE_TEMP where CONTIGUOUS_BYTES is not null order by TABLESPACE_NAME, CONTIGUOUS_BYTES desc; select tablespace_name, count(*) "# OF EXTENTS", sum(contiguous_bytes) "TOTAL BYTES" from space_temp group by tablespace_name; spool off drop table SPACE_TEMP /
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15747463/viewspace-772542/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE表空間的碎片整理Oracle
- Tablespace Fragmentation - 表空間碎片問題Fragment
- Oracle 整理表碎片、釋放表的空間Oracle
- oracle表空間檢視Oracle
- 表空間檢測異常的問題診斷
- oracle檢查 小表空間Oracle
- 怎麼檢視oracle表空間,剩餘大小,表空間利用Oracle
- 檢測磁碟空間問題
- 檢測空間是否支援curl
- 檢測空間的路徑
- 查詢表空間已使用空間和空閒空間的簡單檢視
- 如何處理表空間級別,表級別,索引級別的碎片索引
- 檢視資料庫表空間資料庫
- 表空間集自包含檢查
- 測試表的空間壓縮與表空間的關係
- db2檢視錶空間和增加表空間容量DB2
- 檢視單個SQL消耗TEMP表空間以及TEMP表空間使用率SQL
- 檢視ORACLE中表、表空間的大小Oracle
- 檢視oracle表空間使用情況Oracle
- Oracle臨時表空間檢視、新增臨時表空間資料檔案、修改預設臨時表空間 方法!Oracle
- sql檢視所有表空間使用情況SQL
- 檢視ORACLE的表所佔空間大小Oracle
- oracle expdp、impdp匯入從原表空間更換到其他表空間 ----匯入到另個表空間測試Oracle
- 檢視oracle臨時表空間佔用率的檢視Oracle
- Oracle可傳輸表空間測試Oracle
- 分析表空間空閒率並收縮表空間
- 檢視Oracle資料庫表空間大小,是否需要增加表空間的資料檔案Oracle資料庫
- 檢查及設定合理的undo表空間
- oracle 檢視使用者所在的表空間Oracle
- 檢視Oracle的表空間的使用情況Oracle
- 檢視SQL SERVER表的空間使用情況SQLServer
- SQL Server檢視所有表大小,所佔空間SQLServer
- MySQL InnoDB 共享表空間和獨立表空間MySql
- 管理表空間(表空間的屬性)轉貼
- 表空間管理之bigfile表空間設定
- 遷移SYSTEM表空間為本地管理表空間
- MySQL InnoDB 共享表空間和獨立表空間MySql
- 如何檢視Oracle資料庫表空間大小(空閒、已使用),是否要增加表空間的資料檔案...Oracle資料庫