Overview
Global sequences are mainly database-based global sequences.
Note
- The start auto-increment SN can be modified.
- Global sequence provides sequence numbers that are globally unique but may not increase continuously.
- If the auto-increment sequence is used, its value must be null. If you do not specify the value or set it to null, DDM will assign a value by default. The user-defined value may conflict with the assigned auto-increment key value.
Table Type | Sharded | Broadcast | Unsharded |
---|---|---|---|
DB-based | Supported | Supported | Not supported |
Creating an Auto-Increment Sequence
- Connect to a DDM instance.
- Open the required schema.
- Run the following command to create an auto-increment sequence:
create sequence <sequence name >
Note- The auto-increment key should be a BIGINT value. To avoid duplicate values, do not use TINYINT, SMALLINT, MEDIUMINT, INTEGER, or INT as the auto-increment key.
- Run show sequences to view the usage of the auto-increment sequence. If the usage reaches 100%, do not insert data any more and contact DDM technical support.
Dropping an Auto-Increment Sequence
- Connect to a DDM instance.
- Open the required schema.
- Run show sequences to view all global sequences.
- Run the following command to drop an auto-increment sequence:
drop sequence <sequence name >
drop sequence DB.***;
Note- 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 Sequence
- Connect to a DDM instance.
- Open the required schema.
- Run show sequences to view all global sequences.
- Run the command to change the start value:
alter sequence <sequence name > START WITH <start value of the target sequence >
Querying an Auto-Increment Sequence
- Connect to a DDM instance.
- Log in to the target schema.
- Run the following command to view all sequences:
show sequences;
Modifying the Auto-Increment Cache Value
Notice
This feature is only available in kernel 3.0.3 and later versions.
- Connect to a DDM instance.
- Log in to the required schema.
- Run the following command to change cached values of the global sequence of table test:
alter sequence test cache 5000
- Run the following command to view cached values (or INCREMENT values) of the global sequence of table test:
show sequences
Updating Auto-Increment Sequences of All Tables
Notice
This feature is available only in kernel 3.0.4.1 or later.
- Connect to a DDM instance.
- Run the following command to change sequences of all schemas:
fresh all sequence start value
Parent topic: Global Sequence
- Creating an Auto-Increment Sequence
- Dropping an Auto-Increment Sequence
- Modifying the Start Value of an Auto-Increment Sequence
- Querying an Auto-Increment Sequence
- Modifying the Auto-Increment Cache Value
- Updating Auto-Increment Sequences of All Tables