Reorder or reset auto increment primary key

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
3,184 views

1 answer to this question.

0 votes

To reset the IDs of my User table, Usually, I use the following SQL query. 

ALTER TABLE `users` DROP `id`;
ALTER TABLE `users` AUTO_INCREMENT = 1;
ALTER TABLE `users` ADD `id` int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
answered Oct 4, 2019 by Daric
• 500 points

Related Questions In Database

0 votes
0 answers

Auto increment primary key in SQL Server Management Studio 2012

How can I make a SQL Server ...READ MORE

Sep 2, 2022 in Database by Kithuzzz
• 38,000 points
606 views
0 votes
1 answer

Which one is suitable for real time big database- Primary Key or Unique Index?

What is a unique index? A unique index ...READ MORE

answered Oct 12, 2018 in Database by Frankie
• 9,830 points
1,877 views
0 votes
2 answers

Difference between primary key a composite key

candidate  key: It is the collection of ...READ MORE

answered Oct 14, 2020 in Database by anonymous
31,294 views
0 votes
1 answer

Auto Increment in SQL

Auto increment keyword allows the user to ...READ MORE

answered Sep 28, 2018 in Database by DataKing99
• 8,250 points
564 views
0 votes
1 answer

Do I need to add primary key in each and every table?

Hi Shraddha, You have a doubt to add ...READ MORE

answered May 29, 2019 in Database by sampriti
• 1,120 points
1,491 views
+1 vote
1 answer

Do I need to mention primary key for each table?

Hi Pritha, First, there is no hard and ...READ MORE

answered Jul 4, 2019 in Database by sampriti
• 1,120 points
983 views
0 votes
1 answer

How can I define a composite primary key in SQL?

A primary key is unique and it ...READ MORE

answered Feb 21, 2022 in Database by Vaani
• 7,070 points
1,393 views
0 votes
1 answer

Add Auto-Increment ID to existing table?

Try this ALTER TABLE `users` ADD `id` INT ...READ MORE

answered Sep 10, 2022 in Database by narikkadan
• 63,600 points
1,345 views
0 votes
1 answer

Add primary key to existing table

You have to drop constraint and recreate ...READ MORE

answered Sep 12, 2022 in Database by narikkadan
• 63,600 points
598 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP