0

I have tried several ways of setting the auto increment value on the primary key ID on a table with no luck.

Doesn't work for me...

id INT NOT NULL AUTO_INCREMENT = 10000,

Tried this...

UPDATE tablename SET id = id + 10000;

Tried this..

ALTER TABLE tablename AUTO_INCREMENT = 10000;

Tried this..

CREATE TABLE tablename (
    ...
) ENGINE = MyISAM AUTO_INCREMENT = 10000;

enter image description here

What is the proper way to set this when creating a table using SQL?

codeRed
  • 53
  • 1
  • 16

1 Answers1

3

On the creation of the table you can use these SQL statement:

CREATE TABLE tablename (
    ...
) ENGINE = InnoDB AUTO_INCREMENT = 10000;

But, if the table is already created, you can make an ALTER TABLE to let the AUTO_INCREMENT sequence start with another value, use the following SQL statement:

ALTER TABLE tablename AUTO_INCREMENT = 10000;

You can find more on using AUTO_INCREMENT.

Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46
  • 1
    Okay, @codeRed, in what sense is it "not working?" The answer seems correct. – Michael - sqlbot Aug 13 '16 at 21:57
  • In the sense that none of these options are working for me. Either phpmyadmin is spitting out errors, or the numbers are always starting at 1. Im not saying they aren't going to work for someone else or that they are not correct, for some reason it just isn't happening. If I knew why, I wouldn't be here. – codeRed Aug 14 '16 at 07:37