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 ...
随机推荐
- 对RecycleView的多种item布局的封装
本文是借鉴bingoogolapple写得BGAAdapter-Android而产生的,对此表示感谢. 效果 1.Adapter的使用 1.继承BaseAdapter 这里是我的adapter pub ...
- 使用 git 进行项目管理(只管理代码,不管理项目配置)
使用Git进行项目管理 1. 从服务器pull项目,本地还原工程 从服务器拉取仓库及分支 git clone git@github.com/helloWorld.git git branch -a g ...
- Oracle中not exists 与not in 的使用情况
1.在oracle11g以上版本,oracle已经做了优化,能够自动将in优化成exists方式,因此oracle11g以上版本,使用in和exists效果是一样的. 2.在oracle中,使用not ...
- PHP 发邮件不换行
Content-Type:用于定义用户的浏览器或相关设备如何显示将要加载的数据,或者如何处理将要加载的数据 MIME:MIME类型就是设定某种扩展名的文件用一种应用程序来打开的方式类型,当该扩展名文件 ...
- [综合|基础|语法] 最新的皮肤帮助类 UI_Misc_Helper (转载)
using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace ...
- Handler 原理分析和使用(二)
在上篇 Handler 原理分析和使用(一)中,介绍了一个使用Handler的一个简单而又常见的例子,这里还有一个例子,当然和上一篇的例子截然不同,也是比较常见的,实例如下. import andro ...
- c语言_链表实例讲解(两个经典例子)
建立一个学生成绩的线性链表,对其实现插入,删除,输出,最后销毁. demo1 // lianbiao.cpp : Defines the entry point for the console app ...
- oracle session 相关优化
导读: 同学们是不是都用遇到过这种情况,一个业务系统开发期业务并发量只是估算一个值,而系统上线后这个并发量可能会出现溢出或是不够的 情况.在这种情况下我们DBA怎么给出合理的性能优化建议呢?本文就 ...
- IE str.trim() 不兼容问题解决方法
本文实例分析了javascript在IE下trim函数无法使用的解决方法: 首先,javascript的trim函数在firefox或者chrome下面使用没有问题: 1 2 3 4 5 <sc ...
- [转]深入理解JavaScript系列
文章转自:汤姆大叔-深入理解JavaScript系列文章 深入理解JavaScript系列文章,包括了原创,翻译,转载,整理等各类型文章,如果对你有用,请推荐支持一把,给大叔写作的动力. 深入理解Ja ...