Oracle sequence的基本概念与理解

Posted dayu.liu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle sequence的基本概念与理解相关的知识,希望对你有一定的参考价值。

1.如何查看sequence的定义

2.dba_sequences相关字的定义

3.如何修改sequence

**********************************************************************************************************************************************************

**********************************************************************************************************************************************************

1.如何查看sequence的定义


SQL>SELECT DBMS_METADATA.GET_DDL(SEQUENCE,SEQ_SMECUSTPERIODINFO,CLMS01) FROM DUAL;

CREATE SEQUENCE "CLMS01"."SEQ_SMECUSTPERIODINFO" MINVALUE 1 MAXVALUE 999999
9999 INCREMENT BY 1 START WITH 8798675575 CACHE 20 ORDER NOCYCLE  --START WITH 8798675575 此值为dba_sequneces中的LAST_NUMBER,比较奇怪!!

2.dba_sequences相关字的定义

ColumnDatatypeNULLDescription
SEQUENCE_OWNER VARCHAR2(30) NOT NULL Owner of the sequence
SEQUENCE_NAME VARCHAR2(30) NOT NULL Sequence name
MIN_VALUE NUMBER   Minimum value of the sequence
MAX_VALUE NUMBER   Maximum value of the sequence
INCREMENT_BY NUMBER NOT NULL Value by which sequence is incremented
CYCLE_FLAG VARCHAR2(1)   Indicates whether the sequence wraps around on reaching the limit (Y) or not (N)
ORDER_FLAG VARCHAR2(1)   Indicates whether sequence numbers are generated in order (Y) or not (N)
CACHE_SIZE NUMBER NOT NULL Number of sequence numbers to cache
LAST_NUMBER NUMBER NOT NULL Last sequence number written to disk. If a sequence uses caching, the number written to disk is the last number placed in the sequence cache. This number is likely to be greater than the last sequence number that was used.
  • CYCLE_FLAG:标志sequence是否循环使用(到最大值之后变为最小值)
  • ORDER_FLAG:标志sequence是否是按照顺序生成。
  • CACHE_SIZE:标志内存中缓存的sequence个数(保存在shared pool中),设置较小时会出现row cache lock的等待事件。
  • LAST_NUMBER:不太好理解。

3.如何修改sequence

 



以上是关于Oracle sequence的基本概念与理解的主要内容,如果未能解决你的问题,请参考以下文章

SQL SERVER 2012 SEQUENCE

oracle数据库,批量插入数据脚本

oracle视图与索引

你知道Oracle的Sequence序列吗?

oracle的sequence的next number值

ORACLE Sequence 自增长