ALTER SEQUENCE

ALTER SEQUENCE — change the definition of a sequence generator

Synopsis

ALTER SEQUENCE [ IF EXISTS ] name
    [ AS data_type ]
    [ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
    [ RESTART [ [ WITH ] restart ] ]
    [ CACHE cache ] [ [ NO ] CYCLE ]
    [ OWNED BY { table_name.column_name | NONE } ]
ALTER SEQUENCE [ IF EXISTS ] name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER SEQUENCE [ IF EXISTS ] name RENAME TO new_name
ALTER SEQUENCE [ IF EXISTS ] name SET SCHEMA new_schema
        

Description

ALTER SEQUENCE changes the parameters of an existing sequence generator. The extended forms of ALTER SEQUENCE are mostly the same as in PostgreSQL (see ALTER SEQUENCE) except for the following differences:

  • The minimum sequence value parameter in Shardman works more like a lower boundary on the global interval of available values, so it can only be increased to make sure no duplicate numbers are generated.

  • The RESTART WITH clause allows restarting a sequence at any arbitrary lower bound, but in this case, there is no guarantee that previously generated numbers will not repeat.

  • Using both RESTART WITH and MINVALUE in a single statement is not permitted to avoid confusion.

Examples

Alter the block size parameter of a sequence called serial:

ALTER SEQUENCE serial SET (block_size = 8192);

pdf