How to make a primary key start from 1000?

人走茶凉 提交于 2019-11-27 07:13:27
davidosomething

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 );

You can use ALTER TABLE to accomplish this:

ALTER TABLE tablename AUTO_INCREMENT = 1000;

If you want it as part of the CREATE TABLE statement, just put it after the table definition:

CREATE TABLE tablename (
  ...
) ENGINE=InnoDB AUTO_INCREMENT=1000;
ALTER TABLE yourtable AUTO_INCREMENT = 1000

Well in such a situation, i simply open up my mysql client software and i type 1000, etc right in the primary key field. The record getting inserted will have ids greater than 1000 now.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!