Oracle中添加自动编号的序列
2015-02-06 15:40
169 查看
1. 创建表T_Test
create table T_Test(id int ,address char(25), pay int);
2. 创建自增序列
create sequence SEQ_T_Test_ID //创建名为zc的序列
increment by 1 //自增长度为1
start with 1 //从1开始计数
minvalue 1 //最小值为1
nomaxvalue //没有最大值
nocache; //不设置缓存
3. 为表T_Test创建触发器
create or replace trigger T_Test_id //将触发器绑定在 id 这一列
before insert
on T_Test
for each row
when(new.id is null)
begin
select SEQ_T_Test_ID.nextval into:new.id from dual;
end;
4. 插入数据
insert into T_Test (address,pay) values('anh3u1i',345);
或者
insert into T_Test values(SEQ_T_Test_ID.nextval,'anh3u1i',345);
create table T_Test(id int ,address char(25), pay int);
2. 创建自增序列
create sequence SEQ_T_Test_ID //创建名为zc的序列
increment by 1 //自增长度为1
start with 1 //从1开始计数
minvalue 1 //最小值为1
nomaxvalue //没有最大值
nocache; //不设置缓存
3. 为表T_Test创建触发器
create or replace trigger T_Test_id //将触发器绑定在 id 这一列
before insert
on T_Test
for each row
when(new.id is null)
begin
select SEQ_T_Test_ID.nextval into:new.id from dual;
end;
4. 插入数据
insert into T_Test (address,pay) values('anh3u1i',345);
或者
insert into T_Test values(SEQ_T_Test_ID.nextval,'anh3u1i',345);
相关文章推荐
- Oracle中添加自动编号的序列
- Oracle中添加自动编号的序列
- oracle序列or自动编号
- 【oracle资料整理】--【9】序列sequence --- 自动编号 ---- IDENTITY (SQLSERVER)
- Oracle下给指定的表添加自动生成序列
- oracle 字段自动编号——触发器实现,非调用序列方法
- oracle创建表,追加备注,添加主键,触发器,自动增长序列
- 关于如何在查询结果中添加自动编号
- ORACLE自动编号
- 如何在DataGrid中添加自动编号的功能
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能
- 如何在查询结果中添加自动编号的方法
- SQL2000查询时加自动编号(序列)
- Oracle自动编号
- oracle自动编号
- oracle 自动编号谈
- [原创]给DataGrid快速添加自动编号
- 给DataGrid添加index序号,自动编号