首先在表中創建一個字段:
alter table moduleinfo add budgetId varchar2(10);
若要加入不爲空,則必須給該字段一個默認值:defult (0) 再加上not null,否則會報爲空,不可添加。
然後創建一個序列:
create sequence SEQ_BUDGETID
minvalue 500
maxvalue 9999999999999
start with 500
increment by 1
cache 20;
最後修改該列的值即可:
update BudgetNumberInfo a set a.budgetId=SEQ_BUDGETID.Nextval where a.budgetid is null;