Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Sequence Objects Quick Reference - Oracle

RSS
Modified on Fri, Jan 09, 2009, 12:19 PM by Administrator Categorized as Oracle, Quick Reference

Definition

A sequence is a schema object that can generate unique sequential values. These values are often used for primary and unique keys. You can refer to sequence values in SQL statements with the following pseudocolumns.

CURRVALreturns the current value of a sequence
NEXTVALincrements the sequence and returns the next value

Usage

From the Current Schema

You must qualify CURRVAL and NEXTVAL with the name of the sequence.

    sequence.CURRVAL
    sequence.NEXTVAL

From Another Schema

To refer to the current or next value of a sequence in the schema of another user, you must have been granted either SELECT object privilege on the sequence or SELECT ANY SEQUENCE system privilege, and you must qualify the sequence with the schema containing it.

    schema.sequence.CURRVAL
    schema.sequence.NEXTVAL

From a Remote Database

To refer to the value of a sequence on a remote database, you must qualify the sequence with a complete or partial name of a database link.

    schema.sequence.CURRVAL@dblink
    schema.sequence.NEXTVAL@dblink

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.