Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:16:09+00:00 2026-05-27T05:16:09+00:00

I have a table in which the first column is auto increment id defined

  • 0

I have a table in which the first column is auto increment id defined like this INT UNSIGNED PRIMARY KEY AUTO_INCREMENT

Now I want to delete some rows which contains NULL, after that, the id is not consistent, is there any way to make them adjust automatically? Like now I delete the first row, so the id begins from 2 in my table and also I deleted some rows in the middle.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:16:10+00:00Added an answer on May 27, 2026 at 5:16 am

    It’s the primary key and it’s not supposed to follow the logic you think it does. If you have sequential values 1, 2, 3, 4, 5 and then you delete value with id = 3, you cannot reuse value 3.

    Implications are severe, just do not try to force MySQL to reuse values that you have deleted.

    If you need some sort of sequencing for “beautiful” display purposes, don’t rely on the value of the id column. It’s a primary key, it exists only so that each row can be uniquely identified, thus making its actual value meaningless in terms of the outside world.

    I know that people usually want their numbers sequential and that gaps look ugly, but if you need to implement that, implement it using some other column that you’ll manually update.

    Remember, never touch the primary key yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in which the first column is auto_increment. I want to
i have a table (tbl_world) which look like this id | first_name | last_name
I have a table which is full of arbitrarily formatted phone numbers, like this
I have a table that looks like this: Id (PK, int, not null) ReviewedBy
In an existing application, I have a table which has no primary key, which
I have a contacts table which contains fields such as postcode , first name
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------
I have a table of web pages, with the primary key as hash of
My problem is: I have a table with an auto_increment column. When I insert
I have a table which has a header row, but also a header column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.