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. float浮动之后高度自适应失效解决方案

    float浮动之后高度自适应失效解决方案 >>>>>>>>>>>>>>>>>>>> ...

  2. javascript 【js‘s word】

    http://mp.weixin.qq.com/s?__biz=MjM5MzY2NDY0Ng==&mid=214013689&idx=1&sn=21e03f6c7bf73893 ...

  3. js--小结⑤

    js中的for循环,while循环,do...while循环和C语言的一模一样 有几个问题要提醒一下的是 1.  null是对象,即object       undefined是undefined d ...

  4. 常见sql语句及复杂sql语句记录

    1 将A表中的部分字段和B表中的部分字段作为C表的字段 SELECT a.name,b.age   FROM  (SELECT * from A) as a,(SELECT * from B) as ...

  5. Asp.Net Remove Unwanted Headers

    原文:http://blogs.msdn.com/b/varunm/archive/2013/04/23/remove-unwanted-http-response-headers.aspx 原文:h ...

  6. SetConsoleCtrlHandler 处理控制台消息

    转载自csdn:http://blog.csdn.net/zhongguoren666/article/details/8770615   SetConsoleCtrlHandler 处理控制台消息 ...

  7. HTML5教程:课时一HTML简介

    一.HTML5新特性 1.HTML5多媒体:标签:视频<video>  :音频<audio> 2.HTML5应用:  本地数据存储:访问本地文件: 本地SQL数据:缓存引用: ...

  8. Object-C添加方法

    给实例变量添加getter方法: #import <Cocoa/Cocoa.h> @interface Photo:NSObject { NSString *caption; NSStri ...

  9. HDU1557权利选举

    /* 思路:遍历所有2^n个集合,对于每个集合求票和,如果满足票为优胜团体,而再对集合每个成员比较,是否满足变成非优胜团体,是的话,对于该成员对应结果+1. 重点:利用二进制思想,所有团体均对应0~2 ...

  10. [设计模式]解释器(Interpreter)之大胆向MM示爱吧

    为方便读者,本文已添加至索引: 设计模式 学习笔记索引 写在前面 “我刚写了个小程序,需要你来参与下.”我把MM叫到我的电脑旁,“来把下面这条命令打进去,这是个练习打(Pian)符(ni)号(de)的 ...