Oracle database-Design automatic growth sequence (Oracle 11g)-Notes

Source: Internet
Author: User
In many databases there is a data type called an automatic growth column. Almost all relational databases support the operation of automatic growth columns, but only Oracle is special, he only provides an automatic growth column after the Oracle 12C version, none of which has been done before, and all similar operations must be handled in a sequential fashion.
a version prior to Oracle 12C can only be handled manually.

* * The creation syntax of the sequence * * Create
SEQUENCE sequence name;
[INCREMENT by step] [Start with start value]
[MAXVALUE max value | Nomaxvalue]
[MinValue min | Nominvalue]
[CYCLE | Nocycle]
[Cache Caching Data | NoCache]

In most cases, only default sequences are created when using a sequence
Create a default sequence seq:
CREATE SEQUENCE seq;

The default sequence is a minimum value of 1, no maximum, starting value of 0, and 20 cached data set
To view the sequence properties:
SELECT * from User_sequences;

Information for the query to SEQ:
Sequence name (sequence_name): seq

Sql> SET linesize 300;
sql> SET PAGESIZE 30;
Sql> SELECT * from User_sequences;

Name of the sequence_name sequence: seq
Min_value Minimum Value: 1
Max_value max value: 1.0000E+28
increment_by Step Size: 1
CY Loop: N
OR
Cache_size Cache 20
Last_number Last content 1

So now that the sequence has been created, and then you need to use this sequence, you can use two pseudo column operations for a sequence:
The object of the sequence. Nextval: Represents the growth of the sequence, with each invocation, the sequence plus the specified step size;
The object of the sequence. Currval: Means to get the current sequence content, regardless of how it is invoked, the contents of the sequence do not change

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.