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 478113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:39:32+00:00 2026-05-13T00:39:32+00:00

I had a quick question on serial data types used on primary key on

  • 0

I had a quick question on serial data types used on primary key on informix db’s.

If I delete a row, will the serial key carry on counting or will it re-adjust for any rows that were deleted?

So if current row is serial no 5, I delete number row withs serial no 3, will the next value be 6 and keep carrying on? Is serial no 3 that is now deleted forever lost not to be used again?

  • 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-13T00:39:33+00:00Added an answer on May 13, 2026 at 12:39 am

    The counter used by SERIAL, SERIAL8 or BIGSERIAL is monotonically increasing until it wraps around. Deleted values are simply deleted. If you insert a literal value that is larger than the counter, the counter is adjusted so that the next inserted value is one bigger:

    CREATE TABLE s (s SERIAL(2) NOT NULL PRIMARY KEY, v VARCHAR(20) NOT NULL);
    
    INSERT INTO s(s,v) VALUES(0, "Row 2");
    INSERT INTO s(s,v) VALUES(0, "Row 3");
    INSERT INTO s(s,v) VALUES(0, "Row 4");
    INSERT INTO s(s,v) VALUES(0, "Row 5");
    DELETE FROM s WHERE s = 3;
    INSERT INTO s(s,v) VALUES(0, "Row 6");
    INSERT INTO s(s,v) VALUES(8, "Row 8"); -- Skip 7
    INSERT INTO s(s,v) VALUES(0, "Row 9");
    
    SELECT * FROM s ORDER BY s;
    

    This generates the results:

              2     Row 2
              4     Row 4
              5     Row 5
              6     Row 6
              8     Row 8
              9     Row 9
    

    All the types behave similarly. If you reach the maximum (2^32-1 for SERIAL, 2^63-1 for SERIAL8 and BIGSERIAL), then the counter wraps back to zero, but you may run into problems with unvacated spaces being reused and the primary key rejected the duplicate rows. Generally, avoid wrapping them. (It takes quite a while to make them wrap, especially the 64-bit counters.)

    Note that you can manually insert a ‘missing’ value – such as 3 or 7. However, IDS will not do that for you.

    @iQ asked:

    So does Informix automatically re-use the unused or deleted serial values when it wraps around?

    Not really. The value wraps back to 1; if the row with value 1 exists, the insert fails; if it doesn’t, it succeeds; either way, the next attempt will try 2. To illustrate, continuing where the last example left off:

    INSERT INTO s(s,v) VALUES(2147483647, "Row 2,147,483,647");
    INSERT INTO s(s,v) VALUES(0, "Row next")     { 1 - Pass };
    INSERT INTO s(s,v) VALUES(0, "Row next + 1") { 2 - Fail };
    INSERT INTO s(s,v) VALUES(0, "Row next + 2") { 3 - Pass };
    INSERT INTO s(s,v) VALUES(0, "Row next + 3") { 4 - Fail };
    SELECT * FROM s ORDER BY s;
    

    The end result is:

              1     Row next            
              2     Row 2               
              3     Row next + 2        
              4     Row 4               
              5     Row 5               
              6     Row 6               
              8     Row 8               
              9     Row 9               
     2147483647     Row 2,147,483,647   
    

    Clearly, the next three inserts would fail, one would succeed, two more would fail, and then they would succeed for the next couple of billion inserts.

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

Sidebar

Ask A Question

Stats

  • Questions 238k
  • Answers 239k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My usual answer is to write a batch script: @echo… May 13, 2026 at 6:54 am
  • Editorial Team
    Editorial Team added an answer http://developer.apple.com/iphone/library/documentation/CoreLocation/Reference/CLHeading_Class/Reference/Reference.html May 13, 2026 at 6:54 am
  • Editorial Team
    Editorial Team added an answer You can monitor events in a WebView using a WebViewClient.… May 13, 2026 at 6:54 am

Related Questions

I just had a quick question about git - how backwards compatible are git
I recently had a question about String and String interning - pretty simple question
Hey all. Quick question on Fluent syntax. I had thought I had this down,
I had a quick function to format a date, here it is: public static

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.