热门关键字:  ubuntu  分区  函数  Fedora  linux系统进程

oracle partition 分区建立详解

来源: 作者: 时间:2008-06-19 Tag: 点击:
Oracle9i通过引入列表分区(List Partition),使得当前共有4种分区数据方法,具体列出如下:

字串9

 

  第一种 范围分区 字串4

  1 对表进行单列范围分区:

字串6

 

  这使最为常用也是最简单方法,具体例子如下: 字串5

  create table emp
  (empno number(4),
  ename varchar2(30),
  sal number)
  partition by range(empno)
  (partition e1 values less than (1000) tablespace emp1,
  partition e2 values less than (2000) tablespace emp2,
  partition e3 values less than (maxvalue) tablespace emp3);
  
  insert into emp values (100,'Tom',1000);
  insert into emp values (500,'Peter',2000);
  insert into emp values (1000,'Scott',3000);
  insert into emp values (1999,'Bill',4000);
  insert into emp values (5000,'Gates',6000);
  commit;
字串6

 

  从emp表中选择全部纪录如下: 字串8

  SQL> select * from emp;
  
  EMPNO ENAME SAL
  ---------- ------------------------------ ----------
  100 Tom 1000
  500 Peter 2000
  1000 Scott 3000
  1999 Bill 4000
  5000 Gates 6000

字串2

 

  还可以按照分区进行选择: 字串6

  SQL> select * from emp partition (e1);
  EMPNO ENAME SAL
  ---------- ------------------------------ ----------
  100 Tom 1000
  500 Peter 2000
  
  SQL> select * from emp partition (e2)
  EMPNO ENAME SAL
  ---------- ------------------------------ ----------
  1000 Scott 3000
  1999 Bill 4000
  
  SQL> select * from emp partition (e3)
  EMPNO ENAME SAL
  ---------- ------------------------------ ----------
  5000 Gates 6000

字串5

 

  使用了分区,还可以单独针对指定分区进行truncate操作: 字串7

  alter table emp truncate partition e2;
字串3

 

  2 对表进行多列范围分区:

字串3

 

  多列范围分区主要是基于表中多个列范围对数据进行分区,例如: 字串1

  drop table emp;
  create table emp
  (empno number(4),
  ename varchar2(30),
  sal number,
  day integer not null,
  month integer not null)
  partition by range(month,day)
  (partition e1 values less than (5,1) tablespace emp1,
  partition e2 values less than (10,2) tablespace emp2,
  partition e3 values less than (maxvalue,maxvalue) tablespace emp3);
  
  SQL> insert into emp values (100,'Tom',1000,10,6);
  SQL> insert into emp values (200,'Peter',2000,3,1);
  SQL> insert into emp values (300,'Jane',3000,23,11);
字串8

 


 

字串7

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册