Oracle 10g 11g分區表建立舉例

來源:互聯網
上載者:User

大家好!

今天整理了10g 11g所有分區表建立的方法樣本,在這裡和大家分享下:

1.1 9i、10g、11gR1、11gR2支援分區情況

          區間      列表      散列

區間    11gR1        9iR2        9iR2   

 

列表      11gR1      11gR1        11gR1

 

散列      11gR2      11gR2        11gR2


註:在Oracle 9iR2及以後版本中,可以先按區間對錶分區然後在每個區間分區中,再按列表或散列進行分區。從11gR1開始,已經從2個組合機制發展到6個。而在11gR2之後,更是有9種組合機制可以選擇。

1.2. 單分區建立舉例

1.2.1.建立定界分割表和全域索引

SQL> create table aning_range

 2 (aning_id number,

 3  aning_name varchar2(100),

 4  aning_date date

 5 )

 6 partition by range (aning_date)

 7 (

 8  partition aning_p1_2010 values less than

 9  (to_date('2011-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss')) tablespace aningtbs1,

 10  partition aning_p2_2011 values less than

 11  (to_date('2012-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss')) tablespace aningtbs2,

 12  partition aning_max values less than (maxvalue)

 13 );

 

Table created.

 

建立enable row movement的定界分割表

SQL> create table aning_range_en_rowmove

 2 (aning_id number,

 3 aning_name varchar2(100),

 4 aning_date date

 5 )

 6 storage (initial 100k next 50k) logging

 7 partition by range (aning_date)

 8 (partition aning_p1_2010 values less than

 9 (to_date('2011-01-01','yyyy-mm-dd')) tablespace aningtbs1 storage (initial 20k next 10k),

 10 partition aning_p2_2011 values less than

 11 (to_date('2012-01-01','yyyy-mm-dd')) tablespace aningtbs2,

 12  partition aning_max values less than (maxvalue)

 13 )

 14 enable row movement;

 

Table created.

 

建立定界分割表全域索引

SQL> create index idx_aning_range on aning_range(aning_date)global;

Index created.

 

SQL> create index idx_aning_range_1 on aning_range(aning_id) global;

Index created.

 

建立索引時,後面加global也不是全域分區索引

建立全域分區索引

SQL> create index idx_aning_range_g on aning_range(aning_date,aning_id)

 2 global partition by range(aning_date)

 3 (partition aning_p1_2010 values less than

 4  (to_date('2011-01-01','yyyy-mm-dd')) tablespace aningtbs1,

 5  partition aning_p2_2011 values less than

 6  (to_date('2012-01-01','yyyy-mm-dd')) tablespace aningtbs2,

 7  partition aning_max values less than (maxvalue)

 8 );

 

Index created.

 

測試Oracle不支援非首碼全域分區索引

SQL> create index idx_aning_range_g on aning_range(aning_id)

 2 global partition by range(aning_date)

 3 (partition aning_p1_2010 values less than

 4  (to_date('2011-01-01','yyyy-mm-dd')) tablespace aningtbs1,

 5  partition aning_p2_2011 values less than

 6  (to_date('2011-01-01','yyyy-mm-dd')) tablespace aningtbs2,

 7  partition aning_max values less than (maxvalue)

 8 );

global partition by range(aning_date)

                                  *

ERROR at line 2:

ORA-14038: GLOBAL partitioned index must be prefixed

 

這裡的首碼是指建立分區索引時的索引分割區鍵

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.