Reorder or reset auto increment primary key

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
1,817 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 in Database by Kithuzzz
• 20,660 points
85 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,115 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
25,414 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,240 points
213 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
396 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
368 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 in Database by Vaani
• 7,020 points
461 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 in Database by narikkadan
• 37,660 points
74 views
0 votes
1 answer

Add primary key to existing table

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

answered Sep 12 in Database by narikkadan
• 37,660 points
66 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