Re: Newbie question

From: Jonathan Leffler <jleffler_at_earthlink.net>
Date: Fri, 17 Jun 2005 05:34:35 GMT
Message-ID: <Lhtse.5488$jX6.1143_at_newsread2.news.pas.earthlink.net>


panther wrote:
> I'd like to know what happens when a counter field defined as
> "primary key" runs into overflow (very big number). How is it
> managed?

It depends on the DBMS. Mountain Man gave you good information on the sizes of integer types. However, the final advice 'The overflow is managed by increasing the integer bound to the next higher classification. [...] ie: [s]imply change the integer type' is answering the question 'what should the database designer and application writer do about the overflow', as opposed to answering the alternative question 'what does the DBMS do when the counter overflows'.   The alternative depends on the DBMS.

In Informix, a SERIAL column wraps from 2**31-1 back to 1 (not 0, not -2**31, not -2**31+1). If the number 1 is still in use - tough; the insert fails on a duplicate value in a unique index (assuming there actually is a unique constraint on the column, as there should be). Other DBMS probably tackle things differently.

-- 
Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com
Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/
Received on Fri Jun 17 2005 - 07:34:35 CEST

Original text of this message