--增加主键ID
alter table CLERK_COMPARE add id number(16);
--设置sequence使ID自增
create sequence SEQ_ID
minvalue 1
maxvalue 999999999
start with 1;
--将id的值设置为sequence
Update clerk_compare set id=seq_id.nextval;
commit;
--设置id为主键
alter table CLERK_COMPARE
add constraint CLERK_COMPARE primary key (ID);
View Code
create sequence SEQ_CLERK_COMPARE_ID minvalue 1 maxvalue 9999999999999990 start with 1 increment by 1 cache 2000 noorder ;
View Code
补充:
1:一个sequence可以被多个表共享。
2:被多个表共享的sequence生成的数字序列始终连续,不会重新开始。
3:如果不再使用的sequence请删除。
作者:习惯沉淀