create sequence seq_test

start with 3

increment by 1

minvalue 1  --范围-(1027 -1)

maxvalue 999999999999999999999999999 ; --范围1028-1

先 seq_test.nextval ,后 seq_test.currval

select seq_test.nextval from dual;

select seq_test.currval from dual;

create sequence seq_test

start with 3

increment by 1

nominvalue  --默认值   --范围-(1027 -1)

nomaxvalue  --默认值    --范围1028-1

cache 20  --默认值

nocycle  --默认值

noorder --默认值;

Use the CREATE SEQUENCE statement to create a sequence, which is a database object from which multiple users may generate unique integers.
 You can use sequences to automatically generate primary key values.

INCREMENT BY

Specify the interval between sequence numbers. This integer value can be any positive or negative integer, but it cannot be 0. This value can have 28 or fewer digits for an ascending sequence and 27 or fewer digits for a descending sequence. The absolute of this value must be less than the difference of MAXVALUE and MINVALUE. If this value is negative, then the sequence descends. If the value is positive, then the sequence ascends. If you omit this clause, then the interval defaults to 1.

START WITH

Specify the first sequence number to be generated. Use this clause to start an ascending sequence at a value greater than its minimum or to start a descending sequence at a value less than its maximum. For ascending sequences, the default value is the minimum value of the sequence. For descending sequences, the default value is the maximum value of the sequence. This integer value can have 28 or fewer digits for positive values and 27 or fewer digits for negative values.

Note:

This value is not necessarily the value to which an ascending or descending cycling sequence cycles after reaching its maximum or minimum value, respectively.

MAXVALUE

Specify the maximum value the sequence can generate. This integer value can have 28 or fewer digits for positive values and 27 or fewer digits for negative values. MAXVALUE must be equal to or greater than START WITH and must be greater than MINVALUE.

NOMAXVALUE

Specify NOMAXVALUE to indicate a maximum value of 1028-1 for an ascending sequence or -1 for a descending sequence. This is the default.

MINVALUE

Specify the minimum value of the sequence. This integer value can have 28 or fewer digits for positive values and 27 or fewer digits for negative values. MINVALUE must be less than or equal to START WITH and must be less than MAXVALUE.

NOMINVALUE

Specify NOMINVALUE to indicate a minimum value of 1 for an ascending sequence or -(1027 -1) for a descending sequence. This is the default.

CYCLE

Specify CYCLE to indicate that the sequence continues to generate values after reaching either its maximum or minimum value. After an ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum value.

NOCYCLE

Specify NOCYCLE to indicate that the sequence cannot generate more values after reaching its maximum or minimum value. This is the default.

CACHE

Specify how many values of the sequence the database preallocates and keeps in memory for faster access. This integer value can have 28 or fewer digits. The minimum value for this parameter is 2. For sequences that cycle, this value must be less than the number of values in the cycle. You cannot cache more values than will fit in a given cycle of sequence numbers. Therefore, the maximum value allowed for CACHE must be less than the value determined by the following formula:

(CEIL (MAXVALUE - MINVALUE)) / ABS (INCREMENT)

If a system failure occurs, then all cached sequence values that have not been used in committed DML statements are lost. The potential number of lost values is equal to the value of the CACHE parameter.

Note:

Oracle recommends using the CACHE setting to enhance performance if you are using sequences in an Oracle Real Application Clusters environment.

NOCACHE

Specify NOCACHE to indicate that values of the sequence are not preallocated. If you omit both CACHE and NOCACHE, then the database caches 20 sequence numbers by default.

ORDER

Specify ORDER to guarantee that sequence numbers are generated in order of request. This clause is useful if you are using the sequence numbers as timestamps. Guaranteeing order is usually not important for sequences used to generate primary keys.

ORDER is necessary only to guarantee ordered generation if you are using Oracle Real Application Clusters. If you are using exclusive mode, then sequence numbers are always generated in order.

NOORDER

Specify NOORDER if you do not want to guarantee sequence numbers are generated in order of request. This is the default.

create sequence的更多相关文章

  1. problem during schema create,statement create sequence act_evt_log_seq

    今天在调试程序的时候出现"problem during schema create,statement create sequence act_evt_log_seq"这个错误,跟 ...

  2. CREATE SEQUENCE添加自增序列及NEXT VALUE FOR返回序列号

    From :https://msdn.microsoft.com/zh-cn/library/ff878091.aspx 语法: CREATE SEQUENCE [schema_name . ] se ...

  3. CREATE SEQUENCE - 创建一个新的序列发生器

    SYNOPSIS CREATE [ TEMPORARY | TEMP ] SEQUENCE name [ INCREMENT [ BY ] increment ] [ MINVALUE minvalu ...

  4. sql: Oracle 11g create table, function,trigger, sequence

    --书藉位置Place目录 drop table BookPlaceList; create table BookPlaceList ( BookPlaceID INT PRIMARY KEY, -- ...

  5. oracle SEQUENCE 创建, 修改,删除

    oracle创建序列化: CREATE SEQUENCE seq_itv_collection            INCREMENT BY 1  -- 每次加几个              STA ...

  6. SQL Server 2012 开发新功能 序列对象(Sequence)(转)

    转载链接:http://www.cnblogs.com/zhangyoushugz/archive/2012/11/09/2762720.html 众所周知,在之前的sqlserver版本中,一般采用 ...

  7. Oracle新表使用序列(sequence)作为插入值,初始值不是第一个,oraclesequence

    Oracle新表使用序列(sequence)作为插入值,初始值不是第一个,oraclesequence 使用oracle11g插入数据时遇到这样一个问题: 1 --创建测试表-- 2 CREATE T ...

  8. Oracle序列(Sequence)创建、使用、修改、删除

    Oracle对象课程:序列(Sequence)创建.使用.修改.删除,序列(Sequence)是用来生成连续的整数数据的对象.序列常常用来作为主键中增长列,序列中的可以升序生成,也可以降序生成.创建序 ...

  9. oracle之sequence详解

    Oracle提供了sequence对象,由系统提供自增长的序列号,每次取的时候它会自动增加,通常用于生成数据库数据记录的自增长主键或序号的地方. sequence的创建需要用户具有create seq ...

随机推荐

  1. jquery动态分页

    最近一直研究jquery的分页效果,刚刚弄好了一个,拿出来与大家分享.分页效果与时光网的差不多. 网址:http://www.mtime.com/movie/news/all/ 先在aspx页面放置一 ...

  2. 【转】BMP图像文件格式

    5.1  BMP图像文件格式 BMP图像文件格式是游戏中常用的图像资源文件格式,BMP图像文件起源早,程序员对BMP都比较熟悉,再加上BMP格式简单,读取和写入非常容易实现,所以无论Windows的还 ...

  3. R语言barplot绘图函数

    barplot 函数用于绘制柱状图,下面对其常用的参数进行一个详细的解释: 1)height : 高度,通过这个参数可以指定要画多少个柱子以及每个柱子的高度,其值有两种格式, 第一种 :向量 vect ...

  4. python 脚本检测python 版本

    通过sys 模块的sys_info可以返回当前python 的版本信息, 其返回值是一个元组, 比如(2, 6, 6, 'final', 0); 表示当前版本为2.6.6 , 我们可以利用这个变量的值 ...

  5. 教你如何架设linux邮件服务器postfix

    检查linux是否有安装postfix和dovecot 检查命令如下: Rpm  -qa |grep  postfix; Rpm –qa |grep dovecot; 如果没有显示任何数据,表明没有安 ...

  6. 你是否有遇到过某个实体类字段(属性)过多的情况,不想每次点的话戳进来(C# 反射)

    贴上一段代码: bureaucraticEntities apply = new bureaucraticEntities(); Type tapp= app.GetType(); Type ttmp ...

  7. 详解ASP.NET Core Docker部署

    前言 在前面文章中,介绍了 ASP.NET Core在 macOS,Linux 上基于Nginx和Jexus的发布和部署,本篇文章主要是如何在Docker容器中运行ASP.NET Core应用程序. ...

  8. PHP curl_setopt函数用法介绍上篇

    最近,学习与实践了php中curl的知识点.在此做个初步的总结: 先看看对于它的基本介绍: curl_setopt函数是php中一个重要的函数,它可以模仿用户的一些行为,如模仿用户登录,注册等等一些用 ...

  9. Project Navigator Help: Creating a Workspace in Xcode

    Creating a Workspace Start a multiproduct development endeavor by creating a workspace. 1.Choose Fil ...

  10. AI逻辑实现-取舍行为树还是状态机

    AI逻辑实现-选择行为树还是状态机? 关注AI的朋友可能会看过赖勇浩翻译的<有限状态机时代终结的10大理由> ,里面谈到了状态机的诸多弊端.同时在ppt(附上下载地址)中述说了行为树的诸多 ...