ホームページ > データベース > mysql チュートリアル > Oracle中Sequence使用的限制

Oracle中Sequence使用的限制

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-06-07 17:24:49
オリジナル
1102 人が閲覧しました

在使用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

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

関連ラベル:
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート