oracle中创建自增长序列
2012-07-06 17:03
302 查看
首先创建序列:
create sequence
[b]incr_stu_id_seq
minvalue 1
start with 1
increment by 1
[/b]
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);
create sequence
[b]incr_stu_id_seq
minvalue 1
start with 1
increment by 1
[/b]
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中利用序列和触发器创建自增长的表
- 为Oracle数据库表创建自动增长序列及Oracle的常见操作
- Oracle 触发器和序列的创建和使用 (自动增长列)
- Oracle 触发器和序列的创建和使用 (自动增长列)
- oracle(01): 创建表,主键自增长,注解,视图,序列
- oracle中创建序列和自增长列的实现方式
- oracle创建表,追加备注,添加主键,触发器,自动增长序列
- <四>Oracle创建sequence序列,实现主键自增长
- oracle中创建自增长序列
- Oracle使用序列创建自增字段(主键自动增长)
- Oracle 表创建序列-触发 实现表ID自动增长
- oracle 创建表sql语句,主键,自增长
- oracle 创建字段自增长实现方式
- oracle序列(sequence)创建失败,无法取值(.nextval),无法删除(drop)解决办法
- oracle 创建表,序列,索引,视图,触发器,函数,存储过程,定时器,包体
- oracle用触发器实现插入记录序列自增长(也可以指定记录序号)
- Oracle序列的创建与重置
- Oracle数据库-设计自动增长序列(Oracle 11g)-笔记
- DB2和Oracle创建序列和查询的区别
- Oracle ADF 创建序列