Re: Keys larger than 2 Billion
Posted in 1996
Topics: General Discussion
marco greco wrote: > --- On Tue, 17 Sep 1996 16:36:00 GMT Nils Myklebust wrote: > }"Mark D. Stock" <marks@west.co.za> wrote: > }:Leonid Belov wrote: > }:> > }:> Serial key will be unique across the whole table regardless of what you use > }:> as primary key - single column or composite key. If you want to have > }:> so much rows you _cannot_ use serial column > } > }:Weeeell, you can drop the system index and create a composite index with the > }:serial column. > } > }Actually a very elegant solution, if the serial datatype keeps going > }round robin. (You might want to test that, or check with Informix.) A > }simple time field in addition would make it unique. > } > Serial does wrap around. However, if the original poster needs that > much data, a serial field is highly unlikely to find an unused value > as soon as it hits the <LINE TOO LONG!> If you have more than 2.1 Billion rows, then there will be NO unused values for SERIAL to allocate. A SERIAL itself does not force uniqueness, it simply creates a unique index by default. If you drop that index and create a composite index with, say, a DATETIME field as Nils suggested, then you can go beyond the 2.1 Billion mark. If you say that SERIAL does wrap then this is one solution. The other solution is to use a DECIMAL field. But then you need code to allocate the next key.... and that's what the other discussions took up. Cheers, -- Mark. +-------------------------------------------------------------------------+ |Mark D. Stock - The West Solutions Group http://www.west.co.za | | | |mailto:marks@west.co.za +------------------------------------------------+ |Tel: +27 11 803 2151 |If it doesn't work... force it! | |Fax: +27 11 803 2189 |If it breaks... it needed replacing anyway! | |Cell: +27 83 250 2325 |Well, that's how I code anyway! | +------------------------+------------------------------------------------+