Database Reference
In-Depth Information
The syntax for the Create-Sequence statement is shown in Figure 11-18 . As you can
see, the statement is quite straightforward, and the clauses self-explanatory.
Figure 11-18. The Create-Sequence Statement
The sequence is accessed via two pseudo columns CURRVAL and NEXTVAL.
Typically, it is accessed via a Select statement to retrieve its current value, or via an
Insert statement to insert data into a table (both statements will be discussed in the next
chapter).
Example 11: The following examples illustrate how a sequence is created and used:
To use the sequence in inserting a row into the table, the following statement may be
embedded into a PL/SQL program block:
To view the current value, do a selection on DUAL (DUAL is the general purpose
pseudo table used when a scalar value which is not stored in a specific database table is
to be displayed):
11.10 Altering and Dropping Sequences
The attributes of a sequence may be modified via the Alter-Sequence statement. Its
syntax is similar to that of the Create-Sequence statement (see Figure 11-19 ): The
following guidelines apply to sequence modification:
Only the owner of a sequence (or a user with alter privilege to the
sequence) can modify it.
Only future sequence numbers are affected by the modification.
To restart a sequence, it has to be deleted and then recreated.
 
Search WWH ::




Custom Search