This topic describes how to change the start value of the auto-increment column in a table. The syntax that is used to change the start value of the auto-increment column in a table in PolarDB-X is the same as the syntax that is used in MySQL.

You can execute the ALTER TABLE statement to change the start value of the sequence that is used to generate values for the auto-increment column in a table. You cannot execute the ALTER TABLE statement to change the sequence type.

ALTER TABLE <table_name> ... AUTO_INCREMENT=<start value>
Note
  • To change the type of a sequence, execute the SHOW SEQUENCES statement to query information about existing sequences. You can obtain the name and type of the sequence from the result that is returned. Then, you can execute the ALTER SEQUENCE statement to change the type of the sequence to another type.
  • You can also execute the ALTER SEQUENCE statement to change the start value of the sequence that is associated with the auto-increment column. In this case, the ALTER SEQUENCE statement works in the same manner as the ALTER TABLE statement.
  • Proceed with caution when you change the start value of the sequence that is associated with the auto-increment column in a table. If you need to change the start value based on your business requirements, you must evaluate the values that exist in the sequence and the rate at which new values are generated. Then, specify a new start value to prevent duplicate values from being generated.