Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

AUTO_INCREMENT Clause

Description

The AUTO_INCREMENT clause can change the initial value of the increment value that is currently defined. However, there should be only one AUTO_INCREMENT column defined.

Syntax

ALTER TABLE table_name AUTO_INCREMENT = initial_value;

  • table_name: Table name
  • initial_value: Initial value to alter
Example

CREATE TABLE t (i int AUTO_INCREMENT);

ALTER TABLE t AUTO_INCREMENT = 5;

 

-- when 2 AUTO_INCREMENT constraints are defined on one table, it returns error.

CREATE TABLE t (i int AUTO_INCREMENT, j int AUTO_INCREMENT);

ALTER TABLE t AUTO_INCREMENT = 5;

 

ERROR: To avoid ambiguity, the AUTO_INCREMENT table option requires the table to have exactly one AUTO_INCREMENT column and no seed/increment specification.

Remark

You must be careful not to violate constraints (such as a PRIMARY KEY or UNIQUE) due to changing the initial value of AUTO_INCREMENT.