Oracle中Sequence使用的限制

php中文网
发布: 2016-06-07 17:24:49
原创
1197人浏览过

在使用Oracle序列的currval和nextval时的限制,在delete,select,update语句的子查询中不能使用sequence的值

在使用oracle序列的currval和nextval时的限制

创建一个序列

create sequence test_seq

minvalue 1

maxvalue 10000000

start with 1

increment by 1

cache 20;

在delete,select,update语句的子查询中不能使用sequence的值

SQL>  delete from test_jy where test_id

delete from test_jy where test_id

ORA-02287: 此处不允许序号

SQL>  select * from test_jy where test_id

select * from test_jy where test_id

ORA-02287: 此处不允许序号

SQL>  update test_jy set test_id=0 where test_id

update test_jy set test_id=0 where test_id

ORA-02287: 此处不允许序号

在查询视图或物化视图时

SQL> select a.* from test_v a where a.userid

select a.* from test_v a where a.userid

ORA-02287: 此处不允许序号

带有distinct操作符的select语句不能使用

SQL> select distinct a.*,test_seq.currval from test_v a ;

select distinct a.*,test_seq.currval from test_v a

ORA-02287: 此处不允许序号

有group by,order by操作的select语句不能使用

SQL>  select  test_jy.*,test_seq.currval from test_jy group by test_jy.test_id;

select  test_jy.*,test_seq.currval from test_jy group by test_jy.test_id

ORA-02287: 此处不允许序号

SQL>  select  test_jy.*,test_seq.currval from test_jy order by test_jy.test_id;

select  test_jy.*,test_seq.currval from test_jy order by test_jy.test_id

ORA-02287: 此处不允许序号

有UNION, INTERSECT, MINUS操作符的语句不能使用

SQL> select  test_jy.*,test_seq.currval from test_jy where test_id=1

2  union

卡拉OK视频制作
卡拉OK视频制作

卡拉OK视频制作,在几分钟内制作出你的卡拉OK视频

卡拉OK视频制作 178
查看详情 卡拉OK视频制作

3  select  test_jy.*,test_seq.currval from test_jy where test_id=2;

select  test_jy.*,test_seq.currval from test_jy where test_id=1

union

select  test_jy.*,test_seq.currval from test_jy where test_id=2

ORA-02287: 此处不允许序号

SQL> select  test_jy.*,test_seq.currval from test_jy where test_id=1

2  intersect

3  select  test_jy.*,test_seq.currval from test_jy where test_id=2;

select  test_jy.*,test_seq.currval from test_jy where test_id=1

intersect

select  test_jy.*,test_seq.currval from test_jy where test_id=2

ORA-02287: 此处不允许序号

SQL> select  test_jy.*,test_seq.currval from test_jy where test_id=1

2  minus

3  select  test_jy.*,test_seq.currval from test_jy where test_id=2;

select  test_jy.*,test_seq.currval from test_jy where test_id=1

minus

select  test_jy.*,test_seq.currval from test_jy where test_id=2

ORA-02287: 此处不允许序号

在select语句中的where子句中

SQL> select  test_jy.* from test_jy where test_id

select  test_jy.* from test_jy where test_id

ORA-02287: 此处不允许序号

在create table或alter table语句的中default值是不能使用sequence

SQL> alter table test_jy modify test_id number(20) default test_seq.currval;

alter table test_jy modify test_id number(20) default test_seq.currval

ORA-00984: 列在此处不允许

还有就在check约束中不能使用

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号