How to manually set seed value as 1000 in MySQL

前端 未结 2 420
醉酒成梦
醉酒成梦 2021-01-04 09:53

I am using MySQL 5. I need to set the seed value as 1000 for my auto increment field. How can I set it?

相关标签:
2条回答
  • 2021-01-04 10:28

    To set when creating your table:

    CREATE TABLE xxx(...) AUTO_INCREMENT = 1000;
    

    To set after creating the table:

    ALTER TABLE xxx AUTO_INCREMENT = 1000; 
    
    0 讨论(0)
  • 2021-01-04 10:28

    If the table already exists, you can do this:

    ALTER TABLE mytable AUTO_INCREMENT = 1000;
    

    But make sure the highest value in the auto_increment column is less than 1000.

    If you are creating a new table, you can do this:

    CREATE TABLE mytable (id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT)
    AUTO_INCREMENT = 1000;
    
    0 讨论(0)
提交回复
热议问题