How do I reset a sequence in Oracle?

后端 未结 18 1283
天命终不由人
天命终不由人 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:50

    alter sequence serial restart start with 1;
    

    This feature was officially added in 18c but is unofficially available since 12.1.

    It is arguably safe to use this undocumented feature in 12.1. Even though the syntax is not included in the official documentation, it is generated by the Oracle package DBMS_METADATA_DIFF. I've used it several times on production systems. However, I created an Oracle Service request and they verified that it's not a documentation bug, the feature is truly unsupported.

    In 18c, the feature does not appear in the SQL Language Syntax, but is included in the Database Administrator's Guide.

提交回复
热议问题