Re: SERIAL data type
Posted in 1995
On Jun 22, 8:53pm, Jeff Cauhape wrote: > Subject: Re: SERIAL data type > >From: cwakins@leia.alloys.rmc.com (Clem Akins) > >Newsgroups: comp.databases.informix > >Subject: SERIAL data type > >Date: 21 Jun 1995 18:13:03 -0400 > > > > There is a way to insert specific values, but it's not easy. > > 1. Alter table from serial to integer. > 2. Drop the index. > 3. Insert values. > 4. Create unique index. > 5. Change type from integer back to serial. Specify new starting above the > last > number you entered. > > I've done this a couple of times. nb: Do you backups first, and make sure > they > are readable! Jeff, Sorry but this is entirely unnecessary. 1) Informix does not require a unique index on a serial column though to enforce uniqueness you must create one or have a unique constraint. 2) If you want to insert a specific value to a serial field all you have to do is insert it. If there isn't a unique index it will be inserted. If there is it will work as long as this is not a duplicate of an existing row. 3) If you manually insert values the database resets the next serial value to the maximum value of the serial field +1. Actually I've never tested this but that is what the manual says. As I generally always want to jump the serial value up a notch to distinguish the data sets entered I do an alter table where the only thing changed is the starting value of the serial field. You never need to change the field to integer or drop and recreate the index. Cheers - Jim -- ----------------------------------------------------------------------------- Jim Gordon DHL Airways Inc. jgordon@us.dhl.com ----------------------------------------------------------------------------- My opinions are my own. They may vary with time but they remain mine!