Sequence operations in Oracle and prior sequence Initialization

Source: Internet
Author: User
1. Create a sequence: createsequencemyseqstartwith1incrementby1nomaxvalueminvalue1 2. initialize the sequence selectmyseq. nextvalfromdu.

Create sequence myseqstart with 1 increment by 1 nomaxvalueminvalue 1 II initialization sequence select myseq. nextval from du

1. Create Sequence
Create sequence myseq
Start with 1
Increment by 1
Nomaxvalue
Minvalue 1

Binary initialization sequence
Select myseq. nextval from dual;
It is worth noting that if you write select myseq. currval from dual directly first, a prompt will be prompted that myseq. currtval has not been defined in this session.

Sequence 3
This sequence can be used only after initialization. We use ibatis as an example.


Select myseq. nextval from dual

<BR>insert into Student(id,name,age)<BR>values(#mid#,#mname#,#mage#)<BR>

Iv. Modification Sequence
When you modify a sequence, the following values cannot be modified:
1. The initial values of the sequence cannot be modified.
The minimum value of Sequence 2 cannot be greater than the current value (currval)
3. the maximum value of the sequence cannot be smaller than the current value (currval)
Alter sequence myseq
Increment by 2

5. Delete Sequence
Drop sequence myseq

,

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.