Managing Sequences

A sequence generates a serial list of unique numbers for numeric columns of a database table. Database sequences are generally used to populate table primary keys.

Topics:

Creating a Sequence

To create a sequence:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. Click Create.

  3. From the list of object types, select Sequence.

  4. Specify the following and click Next:

    • Sequence Name - Enter the name of the sequence.

    • Preserve Case - To have the final sequence name match the case entered in the Sequence Name field, click Preserve Case.

    • Start With - Enter the number of the first sequence. The first reference to sequence_name.nextval returns this number.

    • Minimum Value - Enter the minimum value this sequence can return.

    • Maximum Value - Enter the maximum value this sequence can return.

    • Increment By - Each call to sequence_name.nextval returns a value greater than the last, until the maximum value is reached. Enter the value used to increment to the next sequence number.

    • Cycle - Select this option to restart the sequence number to the minimum value when the maximum value is reached. This is not recommended if using the sequence for primary key creation.

    • Number to Cache - For faster access, specify how many sequence values are stored in memory.

    • Order - Specify ORDER to guarantee that sequence numbers are generated in order of request. This option is necessary if using Real Application Clusters (Oracle RAC).

    A confirmation page appears, which displays the SQL used to create the sequence.

  5. Click Create Sequence.

Browsing a Sequence

To browse a sequence:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Sequences.

  3. From the Object Selection pane, select a sequence.

    The Object Details view appears.

Summary of Available Views

Click the tabs at the top of the page to view different reports about the sequence. Table 1-5 describes all available views.


Table 1-5 Available Views for Sequences

View Description

Object Details

Displays details about the current sequence. Actions you can perform in this view include Alter and Drop.

Grant

Displays a list of grants associated with the sequence. Grant details include grantee, privilege, and grant options. Actions you can perform include Grant and Revoke.

Dependencies

Displays a list of objects that use (or depend) upon this sequence.

SQL

Displays the SQL necessary to re-create this sequence.


Dropping a Sequence

To drop a sequence:

  1. On the Workspace home page, click SQL Workshop and then Object Browser.

    Object Browser appears.

  2. From the Object list, select Sequences.

  3. From the Object Selection pane, select a sequence.

    The Object Details view appears.

  4. Click Drop.

  5. To confirm, click Finish.