今天做测试,创建分区表。表建好后创建索引,结果报错了。
create table t_login
(
id number ,
user_id varchar2(32) not null ,
gmt_view date
)
tablespace testsp
partition by range(gmt_view)
(
partition butl_060501 values less than (to_date('2006-05-01','yyyy-mm-dd')) tablespace testsp,
partition butl_060510 values less than (to_date('2006-05-10','yyyy-mm-dd')) tablespace testsp,
partition butl_060515 values less than (to_date('2006-05-15','yyyy-mm-dd')) tablespace testsp
);
alter table t_login add constraint pk_u_login primary key (id) using index tablespace testsp local;
*
第 1 行出现错误:
ORA-14039: 分区列必须构成 UNIQUE 索引的关键字列子集
那就是说主键必须包含分区字段!!!如果不需要分区字段怎么创建索引呢?
我做了个测试,就是创建表的时候用以下语句:
create table t_login
(
id number ,
user_id varchar2(32) not null ,
gmt_view date ,
CONSTRAINT PRIKEY_test UNIQUE(id) USINGINDEX)
tablespace testsp
partition by range(gmt_view)
(
partition butl_060501 values less than (to_date('2006-05-01','yyyy-mm-dd')) tablespace testsp,
partition butl_060510 values less than (to_date('2006-05-10','yyyy-mm-dd')) tablespace testsp,
partition butl_060515 values less than (to_date('2006-05-15','yyyy-mm-dd')) tablespace testsp
);
创建成功后,然后再到pl/sql里把这个KEY的类型改成PRIMARY就成功了。
呵呵,这样做是不是太麻烦了,谁有更好的方法么?
[ 本帖最后由 听海★蓝心梦 于 2009-10-10 17:56 编辑 ]
|