Om din tabell redan finns:
ALTER TABLE your_table AUTO_INCREMENT = 6000;
Om du skapar din tabell från början:
CREATE TABLE your_table () AUTO_INCREMENT = 6000;
Källa och vidare läsning:
Testfall:
CREATE TABLE users (
user_id int NOT NULL,
name varchar(50),
PRIMARY KEY (user_id)
);
INSERT INTO users VALUES (1, 'Bob');
INSERT INTO users VALUES (2, 'Joe');
INSERT INTO users VALUES (3, 'Paul');
ALTER TABLE users MODIFY user_id int NOT NULL AUTO_INCREMENT;
ALTER TABLE users AUTO_INCREMENT = 6000;
INSERT INTO users (name) VALUES ('Keith');
INSERT INTO users (name) VALUES ('Steve');
INSERT INTO users (name) VALUES ('Jack');
SELECT * FROM users;
+---------+-------+
| user_id | name |
+---------+-------+
| 1 | Bob |
| 2 | Joe |
| 3 | Paul |
| 6000 | Keith |
| 6001 | Steve |
| 6002 | Jack |
+---------+-------+
6 rows in set (0.01 sec)