序列是Oracle特有的,他可以维护一个自增的数字序列,通常从1开始增长,但可以设置。
(1)创建序列:
create sequence seq_student_sno start with 1 increment by 1
(2)使用序列:
insert into student(sno,name) values(seq_student_sno.nextval,'张三'); insert into student(sno,name) values(seq_student_sno.nextval,'李四'); insert into student(sno,name) values(seq_student_sno.nextval,'王五');
select sno,sname from student
(3)删除序列:
drop sequence seq_student_sno