sequence使用
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使用的更多相关文章
- oracle SEQUENCE 创建, 修改,删除
oracle创建序列化: CREATE SEQUENCE seq_itv_collection INCREMENT BY 1 -- 每次加几个 STA ...
- Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等
功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...
- DG gap sequence修复一例
环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...
- Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Sequence Reconstruction 序列重建
Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
- [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 ...
- [LeetCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- [LeetCode] Permutation Sequence 序列排序
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- 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 ...
随机推荐
- Android(java)学习笔记176:BroadcastReceiver之 短信发送的广播接收者
有时候,我们需要开发出来一个短信监听器,监听用户发送的短信记录,下面就是一个案例,这里同样需要使用广播机制. 下面同样是代码示例,MainActivity.java 和 activity_main. ...
- Chapter 5. The Gradle Wrapper 关于gradle wrapper
Most tools require installation on your computer before you can use them. If the installation is eas ...
- git warning: LF will be replaced by CRLF in 解决办法
在使用git的时候,每次执行 #git add "目录" git add . 都会提示这样一个警告消息: warning: LF will be replaced by CRLF ...
- 版本控制SVN与Eclipse4.4.1集成 ( eclipse svn:E175002错误解决 )
Eclipse版本--Luna Service Release 1(4.4.1) SVN版本-----1.8.X 系统OS-------ubuntu 14.04 LTS 1.通过地址安装 Help-& ...
- svn出错问题(用户名密码有修改以及资源url改变时)
用eclipse 同步SVN服务器宛然无法访问了: org.tigris.subversion.javahl.ClientException: RA layer request failed svn: ...
- 自己写的demo---声明异常同时处理异常,或者继续抛出异常
package exception; public class exception { public static void main(String args[]) { /*** * 不能对类型 ex ...
- 随便说一说bootstrap-table插件
如题... bootstrap-table插件是一个js的表格插件 找了一下资料发现并没有多少 这里放一下初始化的语法 这里在html中写一个目标table元素 <table id=" ...
- virtualbox共享文件夹无访问权限问题解决方法
virtualbox共享文件夹无访问权限问题解决方法 早就困扰了,这次新装虚拟机又碰到了,记录下来. 这篇文章主要介绍了virtualbox共享文件夹无访问权限问题解决方法,造成这个问题的原因是不跟v ...
- mws文件中的tab文件改为相对路径
用mapinfo将现有的多个图层(tab)文件保存成一个mws工作空间后,将此mws文件发到另一台电脑上后,打开mws,提示无法打开各个tab文件,文件不存在,显示的路径是当时原电脑添加时的绝对路径. ...
- video,source元素
一,视频 <video src="../[再一次快乐结局]第15集.mp4" controls="controls" width="500&qu ...