即兴的灵感

思维是一种艺术; 艺术需要灵感。

博客好友

最新评论

Oracle表分区总结

    今天国庆节,愿大家玩得开心,好好放松!
    我也想好好放松,到各地旅游,到世界每个地方...
    但...
    ...继续努力!!!

   
不多说题外话了,进入今天主题,如题,今天对Oracle中表分区机制作个总结。

   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 2007-10-01 18:00 poetguo 阅读(5587) 评论(4)  编辑  收藏 所属分类: Oracle

评论

# re: Oracle表分区总结 2007-10-01 20:02 flybean

准确地说,ORACLE中是分区表  回复  更多评论   

# re: Oracle表分区总结 2007-10-01 21:27 improviser

回楼上,在有关网上查询了一下,普遍都是表分区的说法,概念性的东西还真的有争论的趣味。。。  回复  更多评论   

# re: Oracle表分区总结 2008-09-22 14:24 110

谢谢了,  回复  更多评论   

# re: Oracle表分区总结 2008-12-26 16:48 qooler

赛!  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航: