Sequences in Oracle

Source: Internet
Author: User
What is a sequence?

A sequence is a database object used to generate a unique, contiguous integer. A sequence is typically used to automatically generate a value for a primary key or unique key. Sequences can be in ascending order or in descending order.

In fact, the sequence in Oracle is almost a meaning of self-growth in MySQL.

Create a sequence

Creates a sequence. Starting from the sequence Number 10, increase each time 1, the maximum is 2000, do not cycle, and then increase the error

CREATE SEQUENCE seq1
START with 10
INCREMENT by 1
MAXVALUE 2000
Nocycle
CACHE 30;

Access sequence

Access Next:

Seq1. Nextval

Query current:

SELECT seq1. Currval from dual;

Change sequence

ALTER SEQUENCE seq1
MAXVALUE 5000--Max 5000
CYCLE; --Cycle

Delete a sequence

DROP SEQUENCE seq1;

Using the Sys_guid function

SELECT Sys_guid () from dual;

Sequences in 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.