AUTO INCREMENT option for database ID field

Avatar
  • updated
  • Answered
Where is the auto increment option to ID field in database?
Avatar
JacobIMH
  • Answered

Hello, and thanks for your question.

You can use phpMyadmin on the server to manage your MySQL databases. You can simply click on the A_I column check-box for Auto Increment on the far-right of the column you want auto incremented.

If you already have a database column in mind that you'd like to set to Auto Increment, select your database in phpMyAdmin from the left-hand menu under your cPanel username.

Click on Structure beside the table that contains the column you want auto incremented.

Then click on Change beside the column you want auto incremented, place a check in the A_I column, and then click Save.

If you haven't created the table yet, at the bottom of the screen once you've selected your database, under the Create table section name your table and how many columns you want, then click Go and you should see the same options.

If you are just trying to use SQL directly to modify an already existing column to become auto incremented, the syntax would look like this:

ALTER TABLE `User` CHANGE `id` `id` INT(3) NOT NULL AUTO_INCREMENT;

Please let us know if you have any further questions at all.

- Jacob