Oracle sequence 的 order/noorder 選項

來源:互聯網
上載者:User
CREATE SEQUENCE command 

PURPOSE: 
    To create a sequence. A sequence is a database object from which 
    multiple users may generate unique integers. You can use sequences 
    to automatically generate primary key values. 

SYNTAX: 

CREATE SEQUENCE [schema.]sequence 
    [INCREMENT BY integer] 
    [START WITH integer] 
    [MAXVALUE integer | NOMAXVALUE] 
    [MINVALUE integer | NOMINVALUE] 
    [CYCLE | NOCYCLE] 
    [CACHE integer | NOCACHE] 
    [ORDER | NOORDER] 

where: 

schema 
    is the schema to contain the sequence. If you omit schema, Oracle 
    creates the sequence in your own schema. 

sequence 
    is the name of the sequence to be created. 

INCREMENT BY 
    specifies the interval between sequence numbers. This value can be 
    any positive or negative Oracle integer, but it cannot be 0. If 
    this value is negative, then the sequence descends. If the 
    increment is positive, then the sequence ascends. If you omit this 
    clause, the interval defaults to 1. 

MINVALUE 
    specifies the sequence's minimum value. 

NOMINVALUE 
    specifies a minimum value of 1 for an ascending sequence or -10 
    for a descending sequence. 

    The default is NOMINVALUE. 

MAXVALUE 
    specifies the maximum value the sequence can generate. 

NOMAXVALUE 
    specifies a maximum value of 10 
    for a descending sequence. 

The default is NOMAXVALUE. 

START WITH 
    specifies the first sequence number to be generated. You can use 
    this option 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 
    sequence's minimum value. For descending sequences, the default 
    value is the sequence's maximum value. 

CYCLE 
    specifies 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. 

NOCYCLE 
    specifies that the sequence cannot generate more values after 
    reaching its maximum or minimum value. 

    The default is NOCYCLE. 

CACHE 
    specifies how many values of the sequence Oracle preallocates and 
    keeps in memory for faster access. 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. 

NOCACHE 
    specifies that values of the sequence are not preallocated. 

    If you omit both the CACHE parameter and the NOCACHE option, Oracle 
    caches 20 sequence numbers by default. However, if you are using 
    Oracle with the Parallel Server option in parallel mode and you 
    specify the ORDER option, sequence values are never cached, 
    regardless of whether you specify the CACHE parameter or the NOCACHE 
    option. 

ORDER 
    guarantees that sequence numbers are generated in order of request. 
    You may want to use this option if you are using the sequence 
    numbers as timestamps. Guaranteeing order is usually not important 
    for sequences used to generate primary keys. 

NOORDER 
    does not guarantee sequence numbers are generated in order of 
    request. 

    If you omit both the ORDER and NOORDER options, Oracle chooses 
    NOORDER by default. Note that the ORDER option is only necessary to 
    guarantee ordered generation if you are using Oracle with the 
    Parallel Server option in parallel mode. If you are using exclusive 
    mode, sequence numbers are always generated in order. 

PREREQUISITES: 
    To create a sequence in your own schema, you must have CREATE 
    SEQUENCE privilege. 

    To create a sequence in another user's schema, you must have CREATE 
    ANY SEQUENCE privilege. If you are using Trusted Oracle in DBMS MAC 
    mode, your DBMS label must dominate the creation label of the owner 
    of the schema to contain the sequence.  

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.