1.Oracle中实现字段自增可以通过创建序列实现
基本语法:
create sequence sequence_name
start with ** //起始点
increment by ** //每次递增幅度
其中还有其它的要点,如minvalue、maxvalue等,此处不演示
2.实际操作演示
创建一个简易表:
create table tea(
tno varchar(12) primary key not null,
name varchar2(20),
age int,
sex int
);
创建简单序列:
create sequence tea_tno_seq start with 1 increment by 1
插入数据
insert into tea values ('T000'||tea_tno_seq.nextval,'丁一', 55, 1);
insert into tea values ('T000'||tea_tno_seq.nextval,'丁二', 49, 0);
查询结果
select * from tea
截图:
3.总结:对序列有了初步的了解,学习中遇到的了字符串自增的问题,小花了些时间。
(个人学习笔记,如有不足请指正)