oracle中建立自增長序列

2021-06-07 14:02:50 字數 610 閱讀 8513

首先建立序列:

create sequence incr_stu_id_seq

minvalue 1

start with 1

increment by 1

nomaxvalue

nocache;

然後建立觸發器:

create or replace trigger incr_stu_id_trig

before insert on students  

for each row

begin

select incr_stu_id_sequ.nextval into:new.id from dual;

end incr_stu_id_trig;

最後可以使用了:

insert into students(name,major,score) values('zhangsan','history',89);

Oracle建立自增長序列 SEQUENCE

oracle通過建立序列來實現自增張欄位。建立序列的語法 建立序列的語法 create sequence user sequence name increment by n start with n maxvalue n nomaxvalue minvalue n nominvalue 修改序列的語...

oracle自增長序列

例1 建立序列 create sequence abc increment by1 start with 1maxvalue 9999999999 nocycle nocache 語法詳解 create sequence 序列名 increment by n 1 start with n 2 3 4...

自增長序列 serial

serial create table tuniq idserial,name text insert into tuniq name values zero insert into tuniq name values second 表名 欄位名 seq 實現的,每次插入的時候會從這個seq中取值作...