Establish and query Sequence in OracleDatabase

Source: Internet
Author: User
The relevant OracleDatabaseSequence information is as follows: Create the Sequence syntax createsequencelt; schemagt;. lt; table_namegt; _ sincrement

The relevant Oracle Database Sequence information is as follows: create Sequence with the sequence Syntax: lt; schemagt;. lt; table_namegt; _ sincrement

Homepage → Database Technology

Background:

Read News

Establish and query Sequence in Oracle Database

[Date: 2010-02-04] Source: Oracle community Author: Oracle edit [Font:]

The relevant Oracle Database Sequence information is as follows:

Create Sequence syntax

Create sequence . _ S
Increment by 1
Start with 1
Max value 99999999999999999999
Minvalue 1
Nocycle;

Where:
Incerment: value added each time
Start: Sequence start value
Maxvalue: Maximum Sequence Value
Nocycle: When the Sequence reaches the maximum value, it does not start with the same Sequence.

Get the next Sequence Value

Select . Nextval [@ db_link]
From dual;

Query the current Sequence Value

Syntax 1:
Select . Currval [@ db_link]
From dual;

Mark: If "Current DB Session" has not executed nextval, run currval first.
ORA-08002: sequence DB_SESSION_ID.CURRVAL is not yet defined in this session error.

Syntax 2:
Select last_number-1
From all_sequences
Where sequence_name =' ';

Modify Sequence

For example, Alter Sequence MaxValue 999999999999999;

Notes

1) Sequence cannot be directly used after "equation: =". For example, vID: = tomSeq. nextval;
2) Sequence can be directly used in "SQL". For example: insert into tomTable values (tomSeq. nextval ,...);

  • 0
  • Add Blob data type objects in Oracle

    Install MySQL in Ubuntu to obtain the C interface created by mysql. h.

    Oracle

    Image Information

    View All comments in this article (0)

    Comments

    Latest Information

    Popular this week

    Introduction to Linux community-advertisement service-website map-help Info-contact us
    The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.


    Copyright©2006-2014 Linux community All rights reserved Zhejiang ICP backup No. 06018118

    ,

    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.