5
例如我有一個表:如何爲現有表添加自動增量字段並使用行號的序列號填充它?
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」的序列號已經存在的領域呢?
那麼它總是'TABLE_NAME_seq.nextval'? – Xonatron 2012-06-26 16:31:00