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

  • Home
  • SEARCH
  • 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 6042459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:47:34+00:00 2026-05-23T06:47:34+00:00

I am fetching my data with id which is Integer primary key or integer.

  • 0

I am fetching my data with id which is Integer primary key or integer.

But after deleting any row…

After that if we make select query to show all.

But it will give force close because one id is missing.

I want that id can itself take auto increment & decrement.

when i delete a record at the end(i.g. id=7) after this i add a row then id must be 7 not 8. as same when i delete a row in middle(i.g. id=3) then all the row auto specify by acceding.

your idea can help me.

  • 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-23T06:47:34+00:00Added an answer on May 23, 2026 at 6:47 am

    Most systems with auto-incrementing columns keep track of the last value inserted (or the next one to be inserted) and do not ever reissue a number (give the same number twice), even if the last number issued has been removed from the table.

    Judging from what you are asking, SQLite is another such system.

    If there is any concurrency in the system, then this is risky, but for a single-user, single-app-at-a-time system, you might get away with:

    SELECT MAX(id_column) + 1 FROM YourTable
    

    to find the next available value. Depending on how SQLite behaves, you might be able to embed that in the VALUES list of an INSERT statement:

    INSERT INTO YourTable(id_column, ...)
        VALUES((SELECT MAX(id_column) + 1 FROM YourTable), ...);
    

    That may not work; you may have to do this as two operations. Note that if there is any concurrency, the two statement form is a bad ideaTM. The primary key unique constraint normally prevents disaster, but one of two concurrent statements fails because it tries to insert a value that the other just inserted – so it has to retry and hope for the best. Clearly, a cell phone has less concurrency than, say, a web server so the problem is correspondingly less severe. But be careful.

    On the whole, though, it is best to let gaps appear in the sequence without worrying about it. It is usually not necessary to worry about them. If you must worry about gaps, don’t let people make them in the first place. Or move an existing row to fill in the gap when you do a delete that creates one. That still leaves deletes at the end creating gaps when new rows are added, which is why it is best to get over the “it must be a contiguous sequence of numbers” mentality. Auto-increment guarantees uniqueness; it does not guarantee contiguity.

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

Sidebar

Related Questions

I have a couple of methods that do processing after fetching data.I need call
i am making iPad application, in which i am fetching data from Url, after
I am developing an iPhone application in which I am fetching data from a
I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text
I want to create a dynamic (fetching data from the database) XML sitemap which
i created an iPad application, in which i am fetching data from URL, when
I'm fetching data from external database (I cannot edit it so don't suggest that
I'm fetching data for my grid like this SELECT Orders.CustomerID, Orders.OrderTime, OrderItems.ProductID, OrderItems.Quantity FROM
i'm developing a widget that is fetching data from the internet via ajax and
I'm currently creating a C# program which will be fetching some data over https

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.