使用降序索引进行独特检查

时间:2012-02-27 06:30:07

标签: oracle indexing unique

我需要在表上创建一个唯一的检查,sql是这样的:

alter table SAMPLE
add constraint A_B unique (A, B)
using  index 
tablespace MASCITY
pctfree 10
initrans 2
maxtrans 255
storage
(
  initial 64K
  minextents 1
  maxextents unlimited
);

它会自动创建一个唯一索引,但我需要的是a asc和b是desc的索引,就像:

create index A_B_Index on SAMPLE (a asc,b desc);

如何把我的sql字符串?

1 个答案:

答案 0 :(得分:0)

alter table MY_TABLE add constraint UK_X unique (A, B)
using index (create unique index UK_X on MY_TABLE(A asc, b desc));