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
Split Keywords for Post PHP MySQL
Sending Multiple Attachment in an Email Using PHP
MySQL (Or PHP) Group Results by Field Data
PHP String Function to Get Substring Before the Last Occurrence of a Character
Remove Item from Array If It Exists in a 'Disallowed Words' Array
Check If the Query Results Empty Row MySQLi
Best Methods to Clean Up a Hacked Site with No Clean Version Available
How to Use PHP Reserved Names for My Functions and Classes
PHP Keep Checkbox Checked After Submitting Form
Notice: Unknown: Skipping Numeric Key 1 in Unknown on Line 0
Laravel 5.4 Redirection to Custom Url After Login
PHP - Empty $_Post and $_Files - When Uploading Larger Files
Regex & PHP - Isolate Src Attribute from Img Tag
Create a Zip File and Download It
Many Hash Iterations: Append Salt Every Time
What Is the Best Practice to Export Canvas with High Quality Images