oracle 为现有表创建sequence为主键

oracle 为现有表创建sequence为主键:


 1. 增加主键
alter table 表名 add id number(10);

 2. 创建sequence
create sequence ORG_CONCAT_SEQ
minvalue 1
maxvalue 9999999999
start with 41
increment by 1
cache 20;

 3. 将id的值设为sequence
update 表名 set id=ORG_CONCAT_SEQ.nextval;
commit;

 4. 设置id为主键
alter table 表名  add constraint PK_xxx primary key (seq_no)

猜你喜欢

转载自blog.csdn.net/Hehaixia/article/details/103822756