Reorder or reset auto increment primary key

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
65 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
55 views
0 votes
1 answer

Difference between primary key a composite key

Primary key is that column of the table ...READ MORE

answered Sep 5, 2018 in Database by CodingByHeart77
• 3,710 points
2,306 views
0 votes
1 answer

Auto Increment in SQL

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

answered Sep 27, 2018 in Database by DataKing99
• 8,130 points
64 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,100 points
63 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,100 points
94 views
0 votes
1 answer

Key Components of HBase

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

answered Jul 23, 2018 in Database by kurt_cobain
• 9,290 points
113 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,580 points
157 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,130 points
610 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,130 points
52 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
159 views