如果你实在是不会写,也可以用向导的。
在oracle studio中,有建立分区表的向导,很简单,可以自己生成sql语句。
分区表建立好以后,数据是oracle自己确定往哪个分区中存放的,你只需要往表中插入数据就可以。
读取数据的时候,只要你的where条件中有分区索引作为条件,oracle也会自动到该分区去找数据,速度就快多了。
以前我用也一个表,里面有2亿数据,就是用的分区表来保存的。

解决方案 »

  1.   

    在DBAStudio(图形界面)中建立分区,会有sql语法提示。
      

  2.   

    关键是要按照不同的月份存放到不同的磁盘分区中,该表有一个字段是日期型的,表空间已经建好,在建表时用如下语句:
        create table test(
            no   number,
            sale_date date not null)
        partition by range (TO_CHAR(sale_date,'MM'))
        (partition test1 value equals '01' TABLESPACE ts_test1,
         partition test2 value equals '02' TABLESPACE ts_test2)
     问以下,其中的TO_CHAR(sale_date,'MM'))及用equals可以这样写吗?
    有没有其他更好的书写方法?
    急!!
      

  3.   

    可以这样写:
    create table test(
            no   number,
            sale_date date not null)
        partition by range (TO_NUMBER(to_char(sale_date,'MM')))
        (partition test1 value less than  2  TABLESPACE ts_test1,
         partition test2 value less than  3 TABLESPACE ts_test2)
      

  4.   

    你说的这种方法好像不行。
    总是提示说第四行缺少右括号
    可实际上根本就不缺少。ERROR 位于第 4 行:
    ORA-00907: 缺少右括号
    谁能帮帮我呀!!!
    help!!!
    在线等待!!!
      

  5.   

    你参考一下吧建立分区表
    create table partition_test
    (
     id number(9),
     tmpStr varchar2(10)
    )
    partition by range(id)
    (
     partition id01 values less than (3000000)  tablespace test_tabspc1,
     partition id02 values less than (6000000)  tablespace test_tabspc2,
     partition id03 values less than (9000000)  tablespace test_tabspc3,
     partition id04 values less than (12000000) tablespace test_tabspc4,
     partition id05 values less than (MAXVALUE) tablespace test_tabspc5
    )
    /1、建立局部分区索引
    Create index your_index on caishui.partition_test(id)
    local

    partition id01 tablespace test_tabspc1,
    partition id02 tablespace test_tabspc2,
    partition id03 tablespace test_tabspc3,
    partition id04 tablespace test_tabspc4,
    partition id05 tablespace test_tabspc5
    )
    /2、重建某一个分区的索引
    alter index your_index rebuild partition id01 tablespace test_tabspc1
    /3、增加分区
    alter table caishui.partition_test
    add partition id06 values less than (15000000) tablespace test_tabspc6
    /
      

  6.   

    谢谢! luckysxn(风子) 
    看来是真的不好解决!
    现在的问题是我的表中的字段名为date型字段。
    而我在建立分区时候要以月份作为分区的标志。而在分区的方法中不能用函数。即
    partition by range (TO_NUMBER(to_char(sale_date,'MM')))中用函数是错误的。谢谢各位了!
      

  7.   

    range(column_list)
    你可以创建一个冗余列,用来表示月份,然后再创建分区
      

  8.   

    或者你应用允许的话,可以用自然月来分区,每个月一个区
    这样你就可以用 values less than了