Oracle Learning (22) sequence (sequence)

Source: Internet
Author: User
Tags integer

When a sequence is invoked for the first time, it returns a predetermined value, and in each subsequent query call, the sequence produces a value that is obtained by its specified increment.

1. Create sequence

The syntax format is as follows:

Create sequence [schema.] Sequence_name  
[Increment by Incre_value]--each increment, by default, is 1*/  
[start with Start_value]--Initial value */  
[MaxValue Integer | Nomaxvalue]--Maximum value */  
[minvalue integer | nominvalue]-min/  
[cycle | nocycle]-cycle/  
[Cache integer | NOCAC He]--buffer set/  
[order | noorder]--serial number is generated in sequence * *

Sample code:

Create sequence mysequence increment by 2-start with 1;

2, the use of the sequence

After the sequence is created, a value is returned each time the Sequence_name.nextval is invoked.

Sample code:

Select Mysequence.nextval from dual;

2, modify the sequence

The syntax format is as follows:

Alter sequence [schema.] Sequence_name  
[Increment by integer_value]  
[MaxValue integer | nomaxvalue]  
[MinValue integer | Nominvalue]  
[cycle | nocycle]  
[Cache integer | nocache]  
[order | noorder]

Sample code:

Alter sequence mysequence increment by 1 MaxValue 1000;

3. Delete sequence

The syntax format is as follows:

Drop sequence sequence_name;

Sample code:

Drop sequence mysequence;

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

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.