Search code examples
postgresqldatabase-sequence

What is the equivalent for NO ORDER of oracle sequence in postgresql?


I have a query

CREATE SEQUENCE  "SEQ_ID"  
    MINVALUE 1 
    MAXVALUE 99999 
    INCREMENT BY 1 START WITH 121 
    CACHE 20 
    NOORDER  
    NOCYCLE; 

This one is of oracle commands.

Now, I want to convert into a PostgreSQL command.

How do I replace NO ORDER here.


Solution

  • How do I replace NO ORDER here.

    Just remove it.

    There is no equivalent, and I you probably didn't need (or specify) it in Oracle to begin with.

    In Oracle ORDER is only needed in a RAC environment and NOORDER is the default.

    So the equivalent would be:

    CREATE SEQUENCE seq_id
        MINVALUE 1 
        MAXVALUE 99999 
        INCREMENT BY 1 START WITH 121 
        CACHE 20 
        NO CYCLE; 
    

    I removed the double quotes because you should avoid those dreaded quoted identifiers.