Re: Serial field value resets (continued)
Posted in 1993
In article <1r3jteINNdtn@emory.mathcs.emory.edu> mark@cdin-1.compu.com writes:
> If there are in fact no records, how can the "next" value be
> anything OTHER than 1?? i.e. WHERE does Informix keep the "max"
> value for a SERIAL field - in the index? If so, shouldn't
> dropping the index after all the records are deleted and recreating
> it resolve the condition?
I guess it depends on your definition of the "next" value. Informix serials
could loosely be defined as "the next value which has never been assigned
before" rather than the "next" value.
They are stored in the partition page for the table, not in the index. This is
also why you can have a serial field without an index.
>I didn't want to "drop" and recreate the table - the table definition is
>fairly long and not setup in an SQL.
You can use dbschema to create the SQL script for the table. You don't have to
type it all in yourself.
> If there ARE records in the file and you ALTER it replacing the
> SERIAL with INTEGER then you global update all the values to 0,
> then ALTER the table back to SERIAL again - will Informix re-
> sequence the records, or will it blow off with a duplicate value
> error?
1. You cannot alter an integer to a serial.
2. If you could, the serial wouldn't care whether you had duplicates unless you
had a unique index on it. If you had had a unique index on the original
serial, you wouldn't be able to update the integers unless you dropped the
index.
June
-----------------------------------------------------------------
June Tong Informix Software, Inc.
Regency Support 4100 Bohannon Drive
(415) 926-6433 Menlo Park, CA 94025
e-mail: junet@informix.com or uunet!infmx!junet
-----------------------------------------------------------------