oracle中使用序列实现id自增
2010-09-01 13:47
489 查看
conn scott/tiger@db890
1、创建序列
create sequence foo_id_seq
nocycle
maxvalue 9999999999
start with 1;
2、使用触发器自增
drop table foo;
create table foo(
id number primary key,
data varchar2(100));
create or replace trigger foo_id_pk
before insert
on foo
for each row
begin
select foo_seq.nextval into :new.id from dual;
end;
/
insert into foo(data)
values('Chirstopher');
insert into foo(id,data)
values(5,'Sean');
1、创建序列
create sequence foo_id_seq
nocycle
maxvalue 9999999999
start with 1;
2、使用触发器自增
drop table foo;
create table foo(
id number primary key,
data varchar2(100));
create or replace trigger foo_id_pk
before insert
on foo
for each row
begin
select foo_seq.nextval into :new.id from dual;
end;
/
insert into foo(data)
values('Chirstopher');
insert into foo(id,data)
values(5,'Sean');
相关文章推荐
- Oracle使用序列和触发器实现自增ID
- Oracle很实用的汇总报表实现方式!grouping_id、rollup的使用
- oracle 序列 + 触发器 实现 ID自动增长
- oracle使用序列和触发器实现主键的自动增长
- 细聊分布式ID生成方法的实现(一个可以使用10年的序列生成器)
- 使用Oracle 序列 和 触发器实现 字段自增长的方法
- 【oracle】oracle数据库建立序列、使用序列实现主键自增
- Oracle使用sequence(序列)+tirgger(触发器)实现auto_increment(主键自增)
- Oracle中使用触发器(trigger)和序列(sequence)模拟实现自增列实例
- oracle 使用触发器实现id自增
- oracle中的ID号实现自增长的方法(序列)
- oracle里面的序列在java里面的实现和使用
- Oracle使用increment实现id自增
- Oracle - 使用序列+触发器实现主键自增长
- oracle中使用序列和触发器实现单个字段值自增长
- Oracle 表创建序列-触发 实现表ID自动增长
- 【Oracle】利用触发器,序列实现id自增长
- Oracle中使用触发器(trigger)和序列(sequence)模拟实现自增列实例
- Oracle使用触发器实现ID自增的问题
- oracle建表实现序列ID自增