How to make a primary key start from 1000?

user198729 picture user198729 · Jan 25, 2010 · Viewed 67k times · Source
create table tablename (
    id integer unsigned not null AUTO_INCREMENT,
    ....
    primary key id
);

I need the primary key to start from 1000.

I'm using MySQL.

Answer

davidosomething picture davidosomething · Jan 25, 2010

If your table has already been created with an auto-increment. so you can use

ALTER TABLE tbl AUTO_INCREMENT = 1000;

otherwise put the AUTO_INCREMENT = 1000; in your CREATE TABLE

it goes before the final );