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. Windows2012中安装PHP-5.6.20+Apache httpd2.4.18+Composer+Laravel+MySQL5.7

    下载软件包 PHP:  http://windows.php.net/downloads/releases/php-5.6.20-Win32-VC11-x64.zip Apache httpd:  h ...

  2. System Operations on AWS - Lab 5W - Managing Resources (Windows)

    登陆到CommandHost实例,通过AWS CLI来管理各个资源 1. 通过Tags来管理资源 1.1 登陆到CommandHost实例 1.2 找出development实例 1.2.1 打开Po ...

  3. jquery easyui textbox onblur事件,textbox blur事件无效解决方案

    jquery easyui textbox onblur事件,textbox blur事件无效解决方案 >>>>>>>>>>>> ...

  4. 调试php的soapCient

    try { import('@.Ext.xml'); header("Content-Type:text/html; charset=utf-8"); $soap = new So ...

  5. android开发:点击缩略图查看大图

    android中点击缩略图查看大图的方法一般有两种,一种是想新浪微博list页面那样,弹出一个窗口显示大图(原activity为背景).另一种就是直接打开一个新的activity显示大图. 1.第一种 ...

  6. css hack方法总结

    IE6识别:下划线 _ 和 星号 *IE7识别:星号 *IE6-IE10识别: \9 css hack方式,条件注释法<!--[if IE]>这段文字只在IE浏览器显示<![endi ...

  7. Spring各种传播特性源码实现的概览

    这几天都在分析Spring的源码实现,看到事务管理的部分 我们知道事务的传播特性有下面几种,我标黄的就是最常用的3中传播特性, Sping在发生事务嵌套的时候,会依据内层事务的传播特性,来决定内层是事 ...

  8. 黑马程序员-集合(二)contains()方法的内部探索

    ------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- 我们知道集合是用来存储对象的.在他们实现了众多的接口我们以Arraylist为列子 所有已实现的 ...

  9. Jenkins integration for AngularJS code coverage

    Install Jenkins plugins 'Cobertura' and 'HTML Publisher' 1. add Post-build Actions "Publish HTM ...

  10. SGU 269. Rooks(DP)

    题意: 给n(<=250)条水平网格,然后在上面放k棋子,每行每列都只能放一个.求方法总数. Solution: 简单的DP, 只要对给出的水平长度排个序就很容易处理了. 需要用到高精度. 偷懒 ...