Auto Increment in PHPmyadmin

How to add auto-increment to column in mysql database using phpmyadmin?

You can add it like this

ALTER TABLE your_table
MODIFY some_column INT NOT NULL AUTO_INCREMENT;

Reset ID autoincrement ? phpmyadmin

ALTER TABLE `table_name` AUTO_INCREMENT=1

Resetting the ID in phpmyadmin

Can be done via phpMyAdmin:

  • On your id column, remove the auto-increment setting
  • Delete your primary key in Structure > indexes
  • Create a new column future_id as primary key, auto_increment
  • Browse your table and verify that the new increments correspond to what you're expecting
  • Drop your old id column
  • Rename the future_id column to id
  • Move the new id column via Structure > Move columns

How can I restart my autoincrement in phpmyadmin?

It is possible, but you shouldn't do that on production.

The SQL query is:

ALTER TABLE tablename AUTO_INCREMENT = 1

The most important part of this is to prevent overriding. For example you have an user and this user has id of 81 and if you delete this user and the database doesn't remember that this id 81 has ever been taken by an user (and for example, you have some relations - like friend lists) the user that is going to have the same ID will probably have the same data.

So basically, you don't want to reset auto increment values.



Related Topics



Leave a reply



Submit