Blog Archive

DB2 set AUTO_INCREMENT value

How To Reset a auto generated Column in DB2 Table

Auto-increment allows a unique number to be generated when a new record is inserted into a table. By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.

What if you need to reset the number back to 1?
  • ALTER TABLE table_name ALTER COLUMN column_name RESTART WITH 1;
What if you need to bump up the number back to say 9999?
  • ALTER TABLE table_name ALTER COLUMN column_name RESTART WITH 9999;