例如我有一张 table :
create table test (testdata varchar2(255));
那么我需要一个自动增量字段:
alter table test add id numeric(10);
create sequence test_seq
start with 1
increment by 1
nomaxvalue;
create trigger test_trigger
before insert on test
for each row
begin
select test_seq.nextval into :new.id from dual;
end;
接下来我应该怎么做才能用“id”中的序列号填充已经存在的字段?
最佳答案
update test
set id = test_seq.nextval
关于sql - 如何为现有表添加自动增量字段并用行的序列号填充它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3599740/