background image

据记录数。要求在建该表的时候使用分区表。这时候我们可以使用序号分区三个区,每个区
中预计存储三千万的数据,也可以使用日期分区,如每五年的数据存储在一个分区上。

根据交易记录的序号分区建表:

SQL> create table dinya_test
  2  (
  3      transaction_id number PRimary key,
  4      item_id number(8) not null,
  5      item_description varchar2(300),
  6      transaction_date date  not null
  7  )
  8  partition by range (transaction_id)
  9  (
 10      partition part_01 values less than(30000000) tablespace dinya_space01,
 11      partition part_02 values less than(60000000) tablespace dinya_space02,
 12      partition part_03 values less than(maxvalue) tablespace dinya_space03
 13  );

Table created.

SQL>

建 表 成 功 , 根 据 交 易 的 序 号 , 交 易

ID 在 三 千 万 以 下 的 记 录 将 存 储 在 第 一 个 表 空 间

dinya_space01 中,分区名为:par_01,在三千万到六千万之间的记录存储在第二个表空间:
dinya_space02 中,分区名为:par_02,而交易 ID 在六千万以上的记录存储在第三个表空间
dinya_space03 中,分区名为 par_03.

根据交易日期分区建表:

SQL> create table dinya_test
  2  (
  3      transaction_id number primary key,
  4      item_id number(8) not null,
  5      item_description varchar2(300),
  6      transaction_date date not null   
  7  )
  8  partition by range (transaction_date)
  9  (
  10 

 partition  part_01  values  less  than(to_date('2006-01-01','yyyy-mm-dd'))  tablespace 

dinya_space01,
  11 

 partition  part_02  values  less  than(to_date('2010-01-01','yyyy-mm-dd'))  tablespace 

dinya_space02,
 12  partition part_03 values less than(maxvalue) tablespace dinya_space03