Example of sequence creation and deletion in Oracle

Source: Internet
Author: User


Create sequence seq_newsIdincrement by 1 start with 1 maxvalue 999999999; select seq_newsid.nextval from sys. dual; Delete sqldrop sequence seq_newsId; www.2cto.com =============================== the sequence used in oracle development is a database object, it can be used to generate a unique integer. Generally, the sequence is used to automatically generate the primary code value. The value of a sequence is automatically generated by a special Oracle program. Therefore, the sequence avoids performance bottlenecks caused by sequence implementation at the application layer. The Oracle sequence allows multiple serial numbers to be generated simultaneously, and each serial number is unique. When a serial number is generated, the sequence is incremental, independent of the commit or rollback of the transaction. The default sequence is allowed and no clause is required. This sequence is an ascending sequence, starting from 1 and increasing to 1. There is no upper limit. 1) CREATE a SEQUENCE command www.2cto.com create sequence [user.] sequence_name [increment by n] [start with n] [maxvalue n | nomaxvalue] [minvalue n | nominvalue]; increment by: Specifies the interval between serial numbers, this value can be a positive or negative integer, but cannot be 0. The sequence is ascending. When this clause is ignored, the default value is 1.
Start with: Specifies the first serial number generated. In ascending order, the sequence can start from a value greater than the minimum value. The default value is the minimum value of the sequence. For descending order, the sequence can start from a value smaller than the maximum value. The default value is the maximum value of the sequence. MAXVALUE: specifies the maximum value that can be generated by the sequence. NOMAXVALUE: set the maximum value to 1027 in ascending order and-1 in descending order. MINVALUE: specifies the minimum value of the sequence. NOMINVALUE: specify the minimum value as 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]. Modify the sequence to modify the INCREMENT of future sequence values. Sets or removes the minimum or maximum value. The number of transition buffer sequences. Specify whether the serial number is ordered. Www.2cto.com 3) Delete SEQUENCE command drop sequence [user.] sequence_name; Delete SEQUENCE from database. Create sequence EXAM_NO_SEQ www.2cto.com start with 1484 MAXVALUE 9999999999 MINVALUE 1 CYCLECACHE 20 NOORDER; prepared by kyle8525_nsn

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: [email protected] 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.