SQL> create sequence seq1

minvalue 1

maxvalue 999999999999999999999999999

start with 0

increment by 1

cache 20;  2    3    4    5    6 

create sequence seq1

*

ERROR at line 1:

ORA-04006: START WITH cannot be less than MINVALUE

提示 起始值不能小于最小值

SQL> create sequence seq1

minvalue 1

maxvalue 999999999999999999999999999

start with 1

increment by 1

cache 20;  2    3    4    5    6

Sequence created.

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1           20     1

SQL>  select seq1.nextval from dual;

NEXTVAL

----------

  1

SQL> /

NEXTVAL

----------

  2

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1           20    21

SQL>  select seq1.nextval from dual;

NEXTVAL

----------

  3

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1           20    21

一次分配20到shared pool中

last_number:

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.

修改cahce大小对sequence的影响呢?

SQL> alter sequence seq1 cache 1000;

Sequence altered.

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1         1000     4

SQL>  select seq1.nextval from dual;

NEXTVAL

----------

  4

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1         1000  1004

那么使用cache是否会导致断号呢?

重启数据库后:

SQL>  select seq1.nextval from dual;

NEXTVAL

----------

  5

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1         1000  1005

居然没有断号,再次重启数据库

SQL> select seq1.nextval from dual;

NEXTVAL

----------

      1005

SQL> select sequence_name,cache_size,last_number  from dba_sequences where sequence_name='SEQ1';

SEQUENCE_NAME         CACHE_SIZE LAST_NUMBER

------------------------------ ---------- -----------

SEQ1         1000  2005

此时已经断号

sequence使用的更多相关文章

  1. oracle SEQUENCE 创建, 修改,删除

    oracle创建序列化: CREATE SEQUENCE seq_itv_collection            INCREMENT BY 1  -- 每次加几个              STA ...

  2. Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等

    功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...

  3. DG gap sequence修复一例

    环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...

  4. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  5. [LeetCode] Sequence Reconstruction 序列重建

    Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...

  6. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

  7. [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...

  8. [LeetCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  9. [LeetCode] Permutation Sequence 序列排序

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  10. Leetcode 60. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

随机推荐

  1. 我的Shell + VIM配置

    1. 安装powerline-shell 下载powerline-shell # cd /opt/ # git clone https://github.com/milkbikis/powerline ...

  2. 获得Radio选中的后面文本框的值

    例如: 选中的radio的值在button中显示 代码如下: <!DOCTYPE html> <html lang="en" xmlns="http:/ ...

  3. 31、三层架构、AJAX+FormsAuthentication实现登陆

    三层架构 前段时间公司要求修改一个网站,打开后我疯了,一层没有都是调用的DB接口,遍地的SQL语句,非常杂乱. 什么是三层架构? 三层架构是将整个项目划分为三个层次:表现层.业务逻辑层.数据访问层.目 ...

  4. 为什么要设置Java环境变量(详解)

    关于java环境变量配置讲解: 1. PATH环境变量.作用是指定命令搜索路径,在shell下面执行命令时,它会到PATH变量所指定的路径中查找看是否能找到相应的命令程序.我们需要把 jdk安装目录下 ...

  5. ASP.NET MVC——Controller的激活

    Controller的激活是根据在路由过程得到的Controller名称来创建对应的Controller对象.相关类如图: Controller激活的过程可通过如下序列图表示: 代码示例如下: str ...

  6. 学习java随笔第十一篇:java窗体程序

    要开java的窗体程序,就要下载开发窗体的工具. 这里我用的是的myeclipse,可以直接在网上下载安装即可. 我用的是10.0版本的,如果需要汉化的话,可以看一下这篇文章:myeclipse.10 ...

  7. 自定义组合控件,适配器原理-Day31

    自定义组合控件,适配器原理-Day31 mobile2.1 主页定义 手机上锁功能 1.弹出设置密码框. 手机下载进度 自定定义控件 控件的属性其实就是控件类一个属性设置属性调用类的set方法方法, ...

  8. android studio或者IntelliJ代码样式的设置

    使用过程中发现了一些与Eclipse不同的地方,在这里提供一些设置方法   1. Backspace会将开头的空格和换行符一并删除,如果要禁用 Settings -> Editor -> ...

  9. ListPreference之entries和entryValues

    在使用PreferenceActivity时,碰到配置文件的ListPreference有两个属性android:entries,android:entryValues.这两个属性其实就和html的o ...

  10. PHP 学习笔记 (一)

    1. 在PHP中设置最长执行时间: PHP中的PHP.ini文件中,max_execution_time 项指定了PHP最长执行时间,默认是30秒.有两种方案可以对其进行修改: 1. 直接在PHP.i ...