// create sequence
create sequence LOG_MAIN_SEG
increment by 1
start with 1
minvalue 1
maxvalue 999999999;
// get autoincrease value
select LOG_MAIN_SEG.Nextval ID from dual;
Below is the learning content:
--创建示例表 --
create table Student(
stuId number(9) not null,
stuName varchar2(20) not null,
stuMsg varchar2(50) null
)
-- 创建序列 Student_stuId_Seq --
create sequence Student_stuId_Seq
increment by 1
start with 1
minvalue 1
maxvalue 999999999;
-- 更改序列 Student_stuId_Seq--
alter sequence Student_stuId_Seq
increment by 2
minvalue 1
maxvalue 999999999;
--获取序列自增ID --
select Student_stuId_Seq.Nextval 自增序列ID from dual;
-- 删除序列 --
drop sequence Student_stuId_Seq;
--调用序列,插入Student数据 --
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'张三');
insert into Student(stuId,Stuname) values(Student_stuId_Seq.Nextval,'李四');
--查询插入的数据 --
select * from Student