This topic describes how to convert all sequences of a specific type in an instance or database to sequences of another type.

Precautions

Before you convert sequences, take note of the following items:
  • During type conversion, you cannot perform other operations on the sequences.
  • We recommend that you convert sequences during off-peak hours or when operations in your business application do not require sequence values.
  • To prevent duplicate values from being generated after the types of sequences are converted from one type to another type, PolarDB-X automatically specifies new start values for the sequences.

Syntax

CONVERT ALL SEQUENCES FROM <source_type> TO <target_type>
[ FOR <database_name> ]

Parameters

Parameter Description
source_type The original type of the sequences that you want to convert. Valid values: NEW, GROUP, and TIME.
target_type The target type to which you want to convert the sequences. Valid values: NEW, GROUP, and TIME.
database_name The name of the logical database. This parameter is optional. If you do not configure this parameter, the specified type of sequences in all logical databases in the current instance are converted to sequences of the target type.

Examples

  • You can execute the following statement to convert all NEW sequences in all databases in the current instance to GROUP sequences:
    CONVERT ALL SEQUENCES FROM NEW TO GROUP;
  • You can execute the following statement to convert all NEW sequences in the database named product in the current instance to GROUP sequences:
    CONVERT ALL SEQUENCES FROM NEW TO GROUP FOR product;