oracle中创建自增字段

create table t_news

(

newsid number not null primary key, //自增字段

title varchar2(50)

)

 

create sequence seq_news

minvalue = 1

maxvalue = 99999999

increment by 1;

 

create or replace trigger t_tri_news

before insert on t_news

for each row

   select seq_news.nextval into :new.newsid from dual;

end;

insert into t_news ( newsid , title)

values( seq_news.nextval ,'aaa');

commit;

你可能感兴趣的:(oracle)