欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

ORACLE中表空間和表碎片的示例分析

這篇文章主要為大家展示了“ORACLE中表空間和表碎片的示例分析”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“ORACLE中表空間和表碎片的示例分析”這篇文章吧。

10年積累的網(wǎng)站制作、網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有青羊免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

表空間碎片率

idle> select a.tablespace_name,sqrt(max(a.blocks)/sum(a.blocks))*(100/sqrt(sqrt(count(a.blocks)))) FSFI
from dba_free_space a,dba_tablespaces b
where a.tablespace_name=b.tablespace_name
and b.contents not in ('TEMPORARY','UNDO')
group by a.tablespace_name 
order by 2;
TABLESPACE_NAME                      FSFI
------------------------------ ----------
EAM                            2.57604251ALM                            20.1734462SYSAUX                         22.2842767SYSTEM                         23.7809729USERS                           53.439579RECCAT                                100ARCH                                  1007 rows selected.
idle> 
123456789101112131415161718192021

數(shù)字越小,表空間碎片較多,當(dāng)小于30%的時(shí)候說明碎片程度很可觀了。

按照表空間顯示連續(xù)的空閑時(shí)間

引用官方的一段話:

The ideal situation is to have one large free extent in your tablespace. The more extents of free space there are in the tablespace, the more likely you will run into fragmentation problems. The size of the free extents is also very important. If you have a lot of small extents (too small for any next extent size) but the total bytes of free space is large, then you may want to consider defragmentation options.

腳本中統(tǒng)計(jì)了連續(xù)空間及對連續(xù)空間求和,當(dāng)表中的總的free空間很大時(shí),但有很多小塊,說明碎片化越嚴(yán)重。

========
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   
/  
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798

表空間級別整理方法

對于ASSM管理的表空間,一般都是由smon進(jìn)程自動(dòng)整理,前提是表空間的pctincrease值為非0,可以將表空間的缺省存儲(chǔ)參數(shù)pctincrease改為非0,一般將其設(shè)為1。如修改temp表空間的pctincrease屬性:alter tablespace temp default storage(pctincrease 1); 這樣就可以自動(dòng)整理表空間級別的碎片整理了。

如果對于字典管理的表空間,可以用下面的命令進(jìn)行整理: 
sql> alter tablespace <表空間名> collesce;

表級別碎片整理方法

1.首選shrink

SQL> alter table t1 enable row movement; --打開行移動(dòng)表已更改。 
SQL> alter table t1 shrink space cascade; --壓縮表及相關(guān)數(shù)據(jù)段并下調(diào)HWMSQL> alter table t1 shrink space compact; --只壓縮不下調(diào)HWMSQL> alter table t1 shrink space ; --下調(diào)HWMSQL> alter table t1 disable row movement; --關(guān)閉行移動(dòng)1234567891011

只能在ASSM、本地管理的表空間進(jìn)行,完成這些之后不需要進(jìn)行索引的重建,但統(tǒng)計(jì)信息最好重新收集下,腳本參加本博客上上篇。^_^

2.導(dǎo)入導(dǎo)出

用exp/imp導(dǎo)出后,重新導(dǎo)入重建,在重新創(chuàng)建索引和重新收集統(tǒng)計(jì)信息。

3.CATS技術(shù)

  1. create table newtable as select * from old_table

  2. drop old_table

  3. rename table newtable to old_table

  4. 重建索引,收集統(tǒng)計(jì)信息。

4.move tablespace

sql> alter table <表名> move tablespace <表空間名>
重建索引,收集統(tǒng)計(jì)信息。123

以上是“ORACLE中表空間和表碎片的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

當(dāng)前標(biāo)題:ORACLE中表空間和表碎片的示例分析
網(wǎng)站路徑:http://chinadenli.net/article10/jiepdo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google手機(jī)網(wǎng)站建設(shè)、網(wǎng)站收錄網(wǎng)站維護(hù)、品牌網(wǎng)站設(shè)計(jì)電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)