乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      ORACLE PARTITION簡介_學(xué)習(xí)空間

       YES_MAN 2009-04-14
      ORACLE PARTITION簡介
      2008-08-27 17:12
      一、Oracle分區(qū)簡介
      ORACLE的分區(qū)是一種處理超大型表、索引等的技術(shù)。分區(qū)是一種“分而治之”的技術(shù),通過將大表和索引分成可以管理的小塊,從而避免了對每個表作為一個大的、單獨的對象進(jìn)行管理,為大量數(shù)據(jù)提供了可伸縮的性能。分區(qū)通過將操作分配給更小的存儲單元,減少了需要進(jìn)行管理操作的時間,并通過增強的并行處理提高了性能,通過屏蔽故障數(shù)據(jù)的分區(qū),還增加了可用性。
      二、Oracle分區(qū)優(yōu)缺點
      優(yōu)點:
      增強可用性:如果表的某個分區(qū)出現(xiàn)故障,表在其他分區(qū)的數(shù)據(jù)仍然可用;
      維護(hù)方便:如果表的某個分區(qū)出現(xiàn)故障,需要修復(fù)數(shù)據(jù),只修復(fù)該分區(qū)即可;
      均衡I/O:可以把不同的分區(qū)映射到磁盤以平衡I/O,改善整個系統(tǒng)性能;
      改善查詢性能:對分區(qū)對象的查詢可以僅搜索自己關(guān)心的分區(qū),提高檢索速度。
      缺點:
      分區(qū)表相關(guān):已經(jīng)存在的表沒有方法可以直接轉(zhuǎn)化為分區(qū)表。不過 Oracle 提供了在線重定義表的功能。
      三、Oracle分區(qū)方法
      范圍分區(qū):
      范圍分區(qū)就是對數(shù)據(jù)表中的某個值的范圍進(jìn)行分區(qū),根據(jù)某個值的范圍,決定將該數(shù)據(jù)存儲在哪個分區(qū)上。如根據(jù)序號分區(qū),根據(jù)業(yè)務(wù)記錄的創(chuàng)建日期進(jìn)行分區(qū)等。
      Hash分區(qū)(散列分區(qū)):
      散列分區(qū)為通過指定分區(qū)編號來均勻分布數(shù)據(jù)的一種分區(qū)類型,因為通過在I/O設(shè)備上進(jìn)行散列分區(qū),使得這些分區(qū)大小一致。
      List分區(qū)(列表分區(qū)):
      當(dāng)你需要明確地控制如何將行映射到分區(qū)時,就使用列表分區(qū)方法。與范圍分區(qū)和散列分區(qū)所不同,列表分區(qū)不支持多列分區(qū)。如果要將表按列分區(qū),那么分區(qū)鍵就只能由表的一個單獨的列組成,然而可以用范圍分區(qū)或散列分區(qū)方法進(jìn)行分區(qū)的所有的列,都可以用列表分區(qū)方法進(jìn)行分區(qū)。
      范圍-散列分區(qū)(復(fù)合分區(qū)):
      有時候我們需要根據(jù)范圍分區(qū)后,每個分區(qū)內(nèi)的數(shù)據(jù)再散列地分布在幾個表空間中,這樣我們就要使用復(fù)合分區(qū)。復(fù)合分區(qū)是先使用范圍分區(qū),然后在每個分區(qū)內(nèi)再使用散列分區(qū)的一種分區(qū)方法(注意:先一定要進(jìn)行范圍分區(qū))
      范圍-列表分區(qū)(復(fù)合分區(qū)):
      范圍和列表技術(shù)的組合,首先對表進(jìn)行范圍分區(qū),然后用列表技術(shù)對每個范圍分區(qū)再次分區(qū)。與組合范圍-散列分區(qū)不同的是,每個子分區(qū)的所有內(nèi)容表示數(shù)據(jù)的邏輯子集,由適當(dāng)?shù)姆秶土斜矸謪^(qū)設(shè)置來描述。(注意:先一定要進(jìn)行范圍分區(qū))

      四、Oracle表分區(qū)表操作
      --Partitioning 是否為true
      select * from v$option s order by s.PARAMETER desc

      --創(chuàng)建表空間
      CREATE TABLESPACE "PARTION_03"
      LOGGING
      DATAFILE 'D:\ORACLE\ORADATA\JZHUA\PARTION_03.dbf' SIZE 50M
      EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO

      --刪除表空間
      drop tablespace partion_01


      --范圍 分區(qū)技術(shù)
      create table Partition_Test
      (
      PID number not null,
      PITEM varchar2(200),
      PDATA date not null
      )
      partition by range(PID)
      (
      partition part_01 values less than(50000) tablespace dinya_space01,
      partition part_02 values less than(100000) tablespace dinya_space02,
      partition part_03 values less than(maxvalue) tablespace dinya_space03
      )

      create table Partition_TTest
      (
      PID number not null,
      PITEM varchar2(200),
      PDATA date not null
      )
      partition by range(PDATA)
      (
      partition part_t01 values less than(to_date('2004-01-01','yyyy-mm-dd')) tablespace dinya_space01,
      partition part_t02 values less than(to_date('2008-01-01','yyyy-mm-dd')) tablespace dinya_space02,
      partition part_t03 values less than(maxvalue) tablespace dinya_space03
      )

      insert into Partition_Test(PID,PITEM,PDATA) select h.id,h.userid,h.rectime from st_handle h

      select * from Partition_Test partition(part_01) t where t.pid = '1961'

      --hash 分區(qū)技術(shù)
      create table Partition_HashTest
      (
      PID number not null,
      PITEM varchar2(200),
      PDATA date not null
      )
      partition by hash(PID)
      (
      partition part_h01 tablespace dinya_space01,
      partition part_h02 tablespace dinya_space02,
      partition part_h03 tablespace dinya_space03
      )

      insert into Partition_HashTest(PID,PITEM,PDATA) select h.id,h.userid,h.rectime from st_handle h

      select * from Partition_HashTest partition(part_h03) t where t.pid = '1961'


      --復(fù)合分區(qū)技術(shù)
      create table Partition_FHTest
      (
      PID number not null,
      PITEM varchar2(200),
      PDATA date not null
      )
      partition by range(PDATA) subpartition by hash(PID) subpartitions 3 store in (dinya_space01,dinya_space02,dinya_space03)
      (
      partition part_fh01 values less than(to_date('2004-01-01','yyyy-mm-dd')) tablespace dinya_space01,
      partition part_fh02 values less than(to_date('2008-01-01','yyyy-mm-dd')) tablespace dinya_space02,
      partition part_fh03 values less than(maxvalue) tablespace dinya_space03
      )

      insert into Partition_FHTest(PID,PITEM,PDATA) select h.id,h.userid,h.rectime from st_handle h

      select * from Partition_FHTest partition(part_fh02) t where t.pid = '1961'

      select * from Partition_FHTest partition(part_fh03) t

      --速度比較
      select * from st_handle h where h.rectime > to_date('2008-01-01','yyyy-mm-dd');

      select * from Partition_FHTest partition(part_fh03) t where t.pdata > to_date('2008-01-01','yyyy-mm-dd');


      --分區(qū)表操作

      --增加一個分區(qū)
      alter table Partition_Test add partition part_05 values less than (10020) tablespace dinya_space03

      --查詢分區(qū)數(shù)據(jù)
      select * from Partition_FHTest partition(part_fh02) t

      --修改分區(qū)里的數(shù)據(jù)
      update Partition_FHTest partition(part_fh02) t set t.PITEM = 'JZHUA' where t.pid = '1961'

      --刪除分區(qū)里的數(shù)據(jù)
      delete from Partition_FHTest partition(part_fh02) t where t.pid = '1961'

      --合并分區(qū)
      create table Partition_HB
      (
      PID number not null,
      PITEM varchar2(200),
      PDATA date not null
      )
      partition by range(PID)
      (
      partition part_01 values less than(50000) tablespace dinya_space01,
      partition part_02 values less than(100000) tablespace dinya_space02,
      partition part_03 values less than(maxvalue) tablespace dinya_space03
      )

      insert into Partition_HB(PID,PITEM,PDATA) select h.id,h.userid,h.rectime from st_handle h

      select * from Partition_HB partition(part_03) t where t.pid = '100001'

      alter table Partition_HB merge partitions part_01,part_02 into partition part_02;

      --拆分分區(qū)
      -- spilt partition 分區(qū)名 at(這里是一個臨界區(qū),比如:50000就是說小于50000的放在part_01,而大于50000的放在part_02中)
      alter table Partition_HB split Partition part_02 at (50000) into (Partition part_01 tablespace dinya_space01, Partition part_02 tablespace dinya_space02);

      --更改分區(qū)名
      alter table Partition_HB rename Partition part_01_test to part_02;
      五、Oracle索引分區(qū)表操作
      分區(qū)表和一般表一樣可以建立索引,分區(qū)表可以創(chuàng)建局部索引和全局索引。當(dāng)分區(qū)中出現(xiàn)許多事務(wù)并且要保證所有分區(qū)中的數(shù)據(jù)記錄的唯一性時采用全局索引。全局索引建立時 global 子句允許指定索引的范圍值,這個范圍值為索引字段的范圍值。其實理論上有3中分區(qū)索引。

      Global索引(全局索引):
      對于 global 索引,可以選擇是否分區(qū),而且索引的分區(qū)可以不與表分區(qū)相對應(yīng)。當(dāng)對分區(qū)進(jìn)行維護(hù)操作時,通常會導(dǎo)致全局索引的 Invalid,必須在執(zhí)行完操作后 Rebuild。Oracle9i 提供了 Update Global Indexes 語句,可以在進(jìn)行分區(qū)維護(hù)的同時重建全局索引。
      1:索引信息的存放位置與父表的Partition(分區(qū))信息完全不相干。甚至父表是不是分區(qū)表都無所謂的。

      create index dinya_idx_t on dinya_test(item_id) global partition by range(item_id) (
      partition idx_1 values less than (1000) tablespace dinya_space01,
      partition idx_2 values less than (10000) tablespace dinya_space02,
      partition idx_3 values less than (maxvalue) tablespace dinya_space03
      );
      2:但是在這種情況下,如果父表是分區(qū)表,要刪除父表的一個分區(qū)都必須要更新Global Index ,否則索引信息不正確
      ALTER TABLE TableName DROP PARTITION PartitionName Update Global Indexes

      Local索引(局部索引):

      對于 local 索引,每一個表分區(qū)對應(yīng)一個索引分區(qū)(就是說一個分區(qū)表一個字段只可以建一個局部索引),當(dāng)表的分區(qū)發(fā)生變化時,索引的維護(hù)由 Oracle 自動進(jìn)行;
      1:索引信息的存放位置依賴于父表的Partition(分區(qū))信息,換句話說創(chuàng)建這樣的索引必須保證父表是Partition(分區(qū)),索引信息存放在父表的分區(qū)所在的表空間。
      2:但是僅可以創(chuàng)建在父表為HashTable或者composite分區(qū)表的。
      3:僅可以創(chuàng)建在父表為HashTable或者composite分區(qū)表的。并且指定的分區(qū)數(shù)目要與父表的分區(qū)數(shù)目要一致。

      create index dinya_idx_t on dinya_test(item_id) local (
      partition idx_1 tablespace dinya_space01,
      partition idx_2 tablespace dinya_space02,
      partition idx_3 tablespace dinya_space03
      );

      不指定索引分區(qū)名直接對整個表建立索引
      create index dinya_idx_t on dinya_test(item_id);

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多