Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have a table with a primary key used as a foreign key in another table, now when I delete the entry the primary keys do not stay in order and I want to reorder them and also want to maintain integrity of foreign key
ALTER TABLE tablename AUTO_INCREMENT = 1
Change 1 to your desired value. for that case prior to execution of this you can sort your table with the primary field and get the highest value.
Required, but never shown