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. android应用一(调用WebServices)

    搞了一个月的android,现学现卖,终于还是搞完了,停下来,整理思路,写写记录吧. 我们知道android访问远程数据库主要有两种协议,一种是SOAP,另外一种就是HTTP.而我们再看看WebSer ...

  2. 【锋利的jQuery】学习笔记04

    第四章 jQuery中的事件和动画 一.jQuery中的事件 加载DOM 在JS中等待页面加载完成通常使用window.onload方法,而在jQuery中则使用$(document).ready() ...

  3. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

    在使用Fragment的过程中,常常会遇到在Activity的onSaveInstanceState方法调用之后,操作commit或者popBackStack而导致的crash. 因为在onSaveI ...

  4. JS一些应用脚本

    脚本一: //重置下标(可以修改成自己所需要的脚本) function ReSetBoxOrder() { var q = 0;//下标值 var a = 0;//暂未用到 //循环当前tbody下的 ...

  5. SET NOCOUNT 的意义.

    SET NOCOUNT 使返回的结果中不包含有关受 Transact-SQL 语句影响的行数的信息. 语法 SET NOCOUNT { ON | OFF } 当 SET NOCOUNT 为 ON 时, ...

  6. C#中的委托范例学习

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...

  7. linux下安装svn(基于编码的方式)

    svn是什么,相信能看到这里的同学应该不会有这个问题了,费话不多说,开始: 1.创建目录 mkdir /home/svn/ 2.获取安装svn所需源文件(svn的官方网址是http://subvers ...

  8. angularjs应用骨架(3)

    好,继续上一章节我们继续聊聊angularjs骨架.开发任何一款优秀的应用都会面临一项非常困难的工作,那就是找到一种合适的方式方法把代码组织在合适的功能范围内.我们已经看过控制器的处理方式,它会提供一 ...

  9. (转)应用内存优化之OnLowMemory&OnTrimMemory

    1.应用内存onLowMemory& onTrimMemory优化 onLowMemory& onTrimMemory简介:OnLowMemory是Android提供的API,在系统内 ...

  10. js 中对象属性的特性

    数据属性: 数据属性包含一个数据值的位置,在这个位置可以读取和写入值. 4个描述的行为特性: writable  表示能否修改属性的值.默认为true Enumerable 表示能否过过for in循 ...