Updated on 2022-12-08 GMT+08:00

Global Sequence

Global sequences are mainly database-based global sequences.

  • The start auto-increment SN can be modified.
  • Global sequence provides sequence numbers that are globally unique but may not increase continuously.
Table 1 Tables supported by global sequence

Table Type

Sharded Table

Broadcast Table

Unsharded Table

DB-based

Supported

Supported

Not supported

Creating an Auto-Increment Sequence

  1. Connect to the target DDM instance using a client.
  2. Open the target schema.
  3. Run the following command to create an auto-increment sequence:

    create sequence xxxxx ;

    • xxxxx indicates the sequence name.

Deleting an Auto-Increment Sequence

  1. Connect to the target DDM instance using a client.
  2. Open the target schema.
  3. Run show sequences to view all global sequences.
  4. Run the following command to delete an auto-increment sequence:

    drop sequence xxxxx ;

    drop sequence DB.xxx;

    • The sequence name is case-insensitive.
    • If an auto-increment sequence is inherent to a table, the sequence cannot be deleted.

Modifying the Start Value of an Auto-Increment Global Sequence

  1. Connect to the target DDM instance using a client.
  2. Open the target schema.
  3. Run show sequences to view all global sequences.
  4. Run the command to change the start value:

    alter sequence xxxxx START WITH yyyyy;

    • xxxxx indicates the sequence name.
    • yyyyy indicates the start value of the target sequence.

Querying an Auto-Increment Sequence

  1. Connect to the target DDM instance using a client.
  2. Open the target schema.
  3. Run the following command to view all global sequences:

    show sequences;

Modifying the Auto-Increment Cache Value

Only kernel 3.0.3 and later versions are supported.

  1. Connect to the target DDM instance using a client.
  2. Open the target schema.
  3. Run command alter sequence test cache 5000 to modify the global sequence cache value of table test.
  4. Run command show sequences to view the cache value (INCREMENT value) of table test.