Please wait while we load your page...
 

Announcements



Webmaster Tutorials

Webmaster Tutorials


Reorder Primary Key
You can reorder a primary key (e.g., ID) by execcuting the following three(3) mySQL queries (via command line or app like phpMyAdmin):

ALTER TABLE `tbl` DROP `col`;
ALTER TABLE `tbl` AUTO_INCREMENT = 1;
ALTER TABLE `tbl` ADD `col` int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

- Replace tbl with the name of your database table.
- Replace col with the name of the column in the database table you are reordering.

Warning: Do NOT reorder a column if another database table uses that same column for reference. Otherwise, the tables will be out of sync.
Once changed, the changes cannot be undone. Always backup your database table before you make sweeping changes like this. That way,
if anything goes wrong, you can restore the database table from your backup.


Last Revised: 2015-09-30 12:09:55

Live Chat Not Available