oracle主键自动增长的设置
来源:互联网 发布:河钢唐钢 云计算 编辑:程序博客网 时间:2024/05/22 10:28
Oracle中为主键设置自增长需要通过序列来完成
1建立数据表
create table Test_Increase(
userid number(10) primary key, /*主键,自动增加*/
username varchar2(20)
);
2创建自动增长序列
CREATE SEQUENCE TestIncrease_Sequence
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
CACHE 10;
3创建触发器
CREATE TRIGGER Test_Increase BEFORE
insert ON Test_Increase FOR EACH ROW
begin
select TestIncrease_Sequence.nextval into:New.userid from dual;
end;
4 提交
commit;
5 测试
反复执行如下语句:
insert into Test_Increase(Username) values('test')
6 查看插入结果:
userid username
1 test
2 test
3 test
4 test
5 test
6 test
7 test
8 test
9 test
- oracle主键自动增长的设置
- oracle设置主键自动增长
- oracle设置主键自动增长
- oracle设置主键自动增长
- oracle 设置主键自动增长
- Oracle 主键自动增长设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle,sqlite 主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle,sqlite 主键自动增长的设置
- Oracle, Mysql,SqlServer主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- Mysql,SqlServer,Oracle主键自动增长的设置
- 对malloc的返回值应该如何转型
- 5.1环型链表概述
- 黑马程序员_银行业务调度系统
- 如何实现在屏幕上有漂亮的刀光效果并有星星环绕
- Faster, Higher, Stronger
- oracle主键自动增长的设置
- PAT中文版1004.成绩排名
- poj 2726
- javascript css html笔记
- arm-linux-objdump
- MySQL教程
- 在VM中安装红帽linux
- 实现红黑树中
- GetLBText()函数