MySQL

Update the Auto Increment Value of a Table in MySQL

Sometime you need to change the Auto-increment value in MySQL so that the next inserted record has a different value.

In this case, the we want to change the last order id in an online shop to something a bit higher so it looks like more orders have gone through.

To see the last inserted value, use this,

SELECT Auto_increment FROM information_schema.tables WHERE table_name='uc_orders';

or

SHOW TABLE STATUS LIKE 'uc_orders'

To set the value,

alter table uc_orders auto_increment = 1234;

done

Leave a Reply