Re: Adding a serial column to a table.
Posted in 1996
You must have enough space to rebuild the table, so:
CREATE new_table (serial_col SERIAL(1) NOT NULL UNIQUE, ... );
INSERT INTO new_table SELECT 0, * FROM old_table;
RENAME old_table TO spare_table;
RENAME new_table TO old_table;
DROP spare_table;
You have to worry about index and constraint names, and possibly about
views as well...
Have fun.
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>From: Spetc@aol.com
>Date: Wed, 6 Mar 1996 11:30:22 -0500
>X-Informix-List-Id: <list.8897>
>
>I'd like to add a serial column to a large (10 million rows) table and I want
>the numbering to be as if it was always there (1-10,000,000)
>
>I can figure out how to do it with load and unload, but this takes forever.
>
>Is there a faster method using SQL / 4GL?