sujata_soman_at_omm-la2-infotech-001@internet.omm.com wrote:
> Hi all,
> Some questions on how Informix handles the "Serial(n)" data type.
> 1. How is the "next serial number" calculated ? why do I sometimes see different
> behaviour(s), for eg, if we have 5 rows, numbered 1 thru 5, and I delete #5, and
> insert a new row :- On some occasions, the new serial number is #5, and on
> others, it is #6 - Why ?
I've never seen this the next record added should always be 6 unless
the record allocated serial number 5 was rolled back and no other row
was added to the table between the rollback and the new insert.
> 2. I once deleted all the rows in a table with a serial number field, and when I
> tried to insert new rows, the serial number had not been updated to 0, ie the
> new numbers picked up from the old set.
Correct. You can use ALTER TABLE to reset the serial number.
> 3. Now, when you create a new table with a serial type column, if you do not
> specify an initial number ( for eg serial(2) vs serial ), does that default to
> 0 ??
Exactly, new tables with serial type columns default to zero (0).
> 4. Are the "holes" in a serial type column ever filled/re-used ??
Not by the automatically generated values, though you can insert rows
with explicit serial numbers and use these 'holes'.
Art S. Kagel