How to set initial value and auto increment in MySQL?

前端 未结 10 1872
Happy的楠姐
Happy的楠姐 2020-11-22 13:40

How do I set the initial value for an \"id\" column in a MySQL table that start from 1001?

I want to do an insert \"INSERT INTO users (name, email) VALUES (\'{

10条回答
  •  情话喂你
    2020-11-22 14:28

    MySQL Workbench

    If you want to avoid writing sql, you can also do it in MySQL Workbench by right clicking on the table, choose "Alter Table ..." in the menu.

    When the table structure view opens, go to tab "Options" (on the lower bottom of the view), and set "Auto Increment" field to the value of the next autoincrement number.

    Don't forget to hit "Apply" when you are done with all changes.

    PhpMyAdmin:

    If you are using phpMyAdmin, you can click on the table in the lefthand navigation, go to the tab "Operations" and under Table Options change the AUTO_INCREMENT value and click OK.

提交回复
热议问题