php使用oracle序列,Oracle 中序列使用详解

Oracle 中序列使用详解: create table test (pid integer primary key, name varchar(20) ); select * from test

logo.jpg

首页 → 数据库技术

背景:

阅读新闻

Oracle 中序列使用详解

[日期:2011-09-13]

来源:Linux社区

作者:myxx520

[字体:]

Oracle 中序列使用详解:

create table test

(pid integer primary key,

name varchar(20)

);

select * from test;

insert into test values(1,'Jack');

create sequence test_seq;--创建序列

select test_seq.nextval from dual;--每次使用后序列加一

select test_seq.currval from dual;--查询当前序列的值

insert into test values(test_seq.nextval,'Jack Or Duck?');--序列的使用

drop sequence test_seq;--删除序列

create sequence test_seq start with 8;--指定序列的初始值

alter sequence test_seq minvalue 9;--设置序列的最小值

alter sequence test_seq maxvalue 9999;--设置序列的最大值

alter sequence test_seq increment by 1;--设置序列的步长

drop sequence test_seq_1;

create sequence test_seq_1 start with 3 minvalue 1 maxvalue 30 increment by 1;

select test_seq_1.nextval from dual;

alter sequence test_seq_1 cycle;

alter sequence test_seq_1 nocycle;--关闭循环取值功能

alter sequence test_seq_1 cache 10;

--设置序列缓存大小的作用,注:序列缓存默认为20

create sequence test_seq_2 start with 1 minvalue 1 maxvalue 20 increment by 3;

alter sequence test_seq_2 cycle;

--上述语句会报错:Cache值必须小于cycle值

alter sequence test_seq_2 increment by 2;

alter sequence test_seq_2 cycle;

--还是报错

alter sequence test_seq_2 increment by 1;

alter sequence test_seq_2 cycle;

--还是报错

alter sequence test_seq_2 maxvalue 21;

alter sequence test_seq_2 cycle;

--不报错了

--或者修改

alter sequence test_seq_1 cache 5;

--start with 1 and maxvalue 10 step 1 then 10 times cycle and bigger than 5

logo.gif

0

了解Oracle权限管理

Oracle PL/SQL之对象权限与系统权限的撤销差异

相关资讯

Oracle教程

图片资讯

本文评论

查看全部评论 (0)

评论声明

最新资讯

本周热门

Linux公社简介 - 广告服务 - 网站地图 - 帮助信息 - 联系我们

本站(LinuxIDC)所刊载文章不代表同意其说法或描述,仅为提供更多信息,,也不构成任何建议。

Copyright © 2006-2011 Linux公社 All rights reserved 浙ICP备06018118号

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值