zoukankan      html  css  js  c++  java
  • create sequence

    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.

  • 相关阅读:
    查看docker程序使用的内存脚本
    shell分割字符串并赋值给变量
    【Ceph】Ceph学习理解Ceph的三种存储接口:块设备、文件系统、对象存储
    删除软连接导致源文件一起被删除
    nginx+keepalived实现双活
    maven私有仓库的搭建
    直接访问nginx ip地址返回404错误
    Solaris基础系列之四:图解Oracle 10g安装
    数据库进阶系列之一:漫谈数据库索引
    Tips&Tricks系列四:C#面试笔试小贴士
  • 原文地址:https://www.cnblogs.com/wwxbi/p/4175883.html
Copyright © 2011-2022 走看看