The use of sequence in oracle development

For details, please click: http://www.verydemo.com/demo_c158_i78137.html

 
A sequence is a database object with which unique integers can be generated. The primary key value is typically generated automatically using a sequence. The value of a sequence is automatically generated by a special Oracle program, so the sequence avoids the performance bottleneck caused by implementing the sequence in the application layer. Oracle sequences allow multiple serial numbers to be generated at the same time, and each serial number is unique. When a sequence number is generated, the sequence is incremented, independent of the commit or rollback of the transaction. Allows to design default sequences without specifying any clauses. The sequence is an ascending sequence, starting at 1 and incrementing by 1, with no upper limit.

    1) Build sequence command

    CREATE SEQUENCE [user.]sequence_name
    [increment by n]
    [start with n]
    [maxvalue n | nomaxvalue]
    [minvalue n | nominvalue];
    INCREMENT BY: Specifies the interval between sequence numbers, which can be positive or negative Integer, but not 0. The sequence is ascending. When this clause is omitted, the default value is 1.
    START WITH: Specifies the first serial number generated. In ascending order, the sequence can start with a value greater than the minimum value, which defaults to the minimum value of the sequence. For descending order, the sequence can start with a value less than the maximum value, which defaults to the maximum value of the sequence.
    MAXVALUE: Specifies the maximum value that the sequence can generate.
    NOMAXVALUE: Specify a maximum value of 1027 for ascending order and -1 for descending order.
    MINVALUE: Specifies the minimum value of the sequence.
    NOMINVALUE: Specifies a minimum value of 1 for ascending order. Specify a minimum value of -1026 for descending order.

    2) Change the sequence command

    ALTERSEQUENCE [user.]sequence_name
    [INCREMENT BY n]
    [MAXVALUE n| NOMAXVALUE ]
    [MINVALUE n | NOMINVALUE];
    Modifying a sequence can:
    ? Modify the increment of future sequence values.
    • Set or undo the minimum or maximum value.
    • Change the number of buffer sequences.
    • Specifies whether serial numbers are ordered.

    3) Delete sequence command

....................................................................

   A statement to create a serial number:

<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->

    The usage of serial number in PB:

<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326664172&siteId=291194637