解析:主键就是索引里面加一个约束
改造一条语句即可,不需要先删除索引,然后重新建立主键。
drop table t_p cascade constraints purge;
CREATE TABLE t_p
(order_id NUMBER(3),
item_id NUMBER(2),
comments varchar2(400));
CREATE INDEX ord_itm_idx ON t_p(order_id,item_id);
alter table t_p add constraint ord_itm_id_pk primary key (order_id,item_id) using index ord_itm_idx ;
---不需要如此操作(差别只是索引名不一样而已)
drop index ord_itm_idx;
alter table t_p add constraint ord_itm_id_pk primary key (order_id,item_id);