posts - 60,comments - 71,trackbacks - 0
          本文來自:http://www.aygfsteel.com/improviser/archive/2007/10/01/150073.html

              Oracle中提供了對表進行分區的機制,通過表分區,可以將表空間中數據按照某種方式分別存放到特定的分區中。表分區的作用:平衡IO操作,分區均勻,提高效率。

             Oracle中表分區方法有:范圍分區法、散列分區法、復合分區法、列表分區法。

           范圍分區:
          語法
          Partition  by  range(); 適合數值型或日期型
           
          示例:
           1 create table Student
           2(
           3     Studentid integer not null,
           4     Studentname varchar2(20),
           5     Score integer
           6)
           7 Partition by range(Score)
           8(
           9     Partition p1 values less than(60),
          10     Partition p2 values less than(75),
          11     Partition p3 values less than(85),
          12     Partition p4 values less than(maxvalue)
          13 );

            散列分區法:根據Oracle內部散列算法存儲,語法 Partition by hash();
           
          實例:
           1 create table department
           2 (
           3     Deptno int,
           4     Deptname varchar2(24)
           5 )
           6 Partition by hash(deptno)
           7 (
           8     Partition p1,
           9     Partition p2
          10 );

            復合分區法:由上面兩種方法復合而成
            示例:

           1 create table salgrade
           2 (
           3     grade number,
           4     losal number,
           5     hisal number
           6 )
           7 Partition by range(grade)
           8 Subpartition by hash(losal,hisal)
           9 (
          10     Partition p1 values less than(10),
          11       (subpartition sp1,subpartition sp2),
          12     Partition p2 values less than(20),
          13       (subpartition sp3,subpartition sp4)
          14 )

            列表分區法:適合字符型 語法Partition by list()
            實例:

           1 create table customer
           2 (
           3     custNo int,
           4     custname varchar(20),
           5     custState varchar(20)
           6 )
           7 Partition by list(custState)
           8 (
           9     Partition saia values('中國','韓國','日本'),
          10     Partition Europe values('英國','俄國','法國'),
          11     Partition ameria values('美國','加拿大','墨西哥'),
          12 );
          13     

          表分區維護:

          添加分區:alter table student add partition p5 values less than(120);
          刪除分區:alter table student drop partition p4;
          截斷分區:alter table student truncate partition p5;
          合并分區:alter table student merge partitions p3,p4 into partition p6;
          posted on 2008-06-18 17:28 henry1451 閱讀(383) 評論(0)  編輯  收藏 所屬分類: Oracle技術
          主站蜘蛛池模板: 临武县| 洛浦县| 天镇县| 广昌县| 隆子县| 池州市| 抚远县| 垫江县| 繁昌县| 偏关县| 永平县| 连城县| 裕民县| 垫江县| 尼木县| 甘德县| 尼勒克县| 兴国县| 重庆市| 宜宾县| 邻水| 新丰县| 福鼎市| 三门县| 邳州市| 敖汉旗| 屏东县| 铜梁县| 通州市| 收藏| 涟源市| 通榆县| 神木县| 奉新县| 东丽区| 诏安县| 张家界市| 西宁市| 安吉县| 兖州市| 都兰县|