- 创建序列
create sequence t_student_seq
minvalue 1
nomaxvalue
start with 1
increment by 1
nocycle
nocache;
说明:
创建索引
create sequence t_student_seq —索引名称
minvalue 1 –最小值
nomaxvalue –不设置最大值
start with 1 –从1开始计数
increment by 1 –每次加1个
nocycle –一直累加,不循环
nocache; –不建缓冲区
- 创建触发器:
create trigger t_student_trigger
before insert on student
for each row
begin
select t_student_seq.nextval into :new.id from dual;
end;
说明:
create trigger (t_student_trigger)----触发器名称
before insert on (student)— 表名
for each row–行级触发
begin
select t_student_seq.nextval into :new.id from dual;
end;