Serial field value resets (continued)
Posted in 1993
Topics: Installation, Setup & Upgrades, Storage & Space Management
I had no idea I would cause such a stir in the net with the question about resetting/restarting the value of a serial field. The original problem was instantiated due to a condition in which all the rows in a table containing a SERIAL field were DELETED, then new records were INSERTED. The problem was that the SERIAL field just picked up from the last value used. E.G. 100 records exist w/ values 1 THRU 100. DELETE ALL FROM <table> INSERT INTO <table> VALUE (0) <----- into serial field. Resulting value = 101. 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 didn't want to "drop" and recreate the table - the table definition is fairly long and not setup in an SQL. Plus, I was doing development on 1 machine and testing on another machine and drop/recreate causes the table_id to be changed and when I installed the new software/table on the test machine I ended up w/ multiple copies of the same data file (the "old" version(s) were inaccessable) which tied up lots of disk space. E.G. table151.dat, table151.idx table181.dat, table181.idx Were actually the same table. ...181 was the "current" version, ...151 was the "old" version. Just for additional yucks.... 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? Thanks guys and gals. Mark -- Mark E. Heringslake CompuData Inc. - Philadelphia, PA Help, I'm in a loop and I can't get Phone: (215) 824-3000 Help, I'm in a loop and I can't get FAX: (215) 824-4423 Help, I'm in a loop and I can't get Help, I'm in a loop and I can't get UUCP: ..!uunet!cdin-1!mark INTERNET: mark@compu.com