How do I reset a sequence in Oracle?

后端 未结 18 1270
天命终不由人
天命终不由人 2020-11-22 05:09

In PostgreSQL, I can do something like this:

ALTER SEQUENCE serial RESTART WITH 0;

Is there an Oracle equivalent?

18条回答
  •  礼貌的吻别
    2020-11-22 05:42

    You can use the CYCLE option, shown below:

    CREATE SEQUENCE test_seq
    MINVALUE 0
    MAXVALUE 100
    START WITH 0
    INCREMENT BY 1
    CYCLE;
    

    In this case, when the sequence reaches MAXVALUE (100), it will recycle to the MINVALUE (0).

    In the case of a decremented sequence, the sequence would recycle to the MAXVALUE.

提交回复
热议问题