Reorder or reset auto increment primary key

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
1,257 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
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,810 points
583 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
19,275 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
149 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
234 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
243 views
0 votes
1 answer

Key Components of HBase

Zookeeper: It does the co-ordination work between client ...READ MORE

answered Jul 24, 2018 in Database by kurt_cobain
• 9,390 points
734 views
0 votes
1 answer

Locking or Transactions MongoDB

MongoDB does not use conventional locking with ...READ MORE

answered Jul 24, 2018 in Database by shams
• 3,660 points
449 views
0 votes
1 answer

Reset a sequence in Oracle

You can try out something like this create ...READ MORE

answered Sep 24, 2018 in Database by DataKing99
• 8,240 points
2,931 views
0 votes
1 answer

IN vs OR in the SQL WHERE Clause

I assume you want to know the ...READ MORE

answered Sep 24, 2018 in Database by DataKing99
• 8,240 points
258 views
0 votes
1 answer

Can I have multiple primary keys in a single table?

A Table can have a Composite Primary Key which ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,810 points
2,053 views