[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2475
  • Last Modified:

Creating Sequences in Oracle 9i

What is the simplest way to create a sequence in Oracle --that is the SQL statement?

I have a trigger that generates an id from from dua0 but I need to create a sequence to go along with it.
0
lcor
Asked:
lcor
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
The basic syntax is something like the following:

    CREATE SEQUENCE YourSequence
        INCREMENT 1
        MINVALUE   1
        MAXVALUE  50000
        START 1
        NOCACHE


You can find a little more detail and examples here: http://www.techonthenet.com/oracle/sequences.htm

Hope this helps.
0
 
helpneedCommented:
hi

use
CREATE SEQUENCE Emp_sequence
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE
    NOCYCLE
    CACHE 10;

Use the SQL command ALTER SEQUENCE to alter a sequence. For example:

ALTER SEQUENCE Emp_sequence
INCREMENT BY 10
    MAXVALUE 10000
    CYCLE
    CACHE 20;

Once a sequence is defined, it can be accessed and incremented by multiple users with no waiting. Oracle does not wait for a transaction that has incremented a sequence to complete before that sequence can be incremented again.

u can use this syntax to insert into table

INSERT INTO Orders_tab (Orderno, Custno)
    VALUES (Order_seq.NEXTVAL, 1032);

The sequence number can also be referenced outermost SELECT of a query or subquery. For example:

SELECT Order_seq.NEXTVAL FROM dual;

regards
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now