Subject | Altering tables |
---|---|
Author | Sandy |
Post date | 2004-02-06T07:59:07Z |
Good morning,
Does anyone know of a more efficient way to perform the following
alteration...
I have a table which is already full of data, and I want to change the
datatype
of one of its columns (this column that needs changing might be the primary
key).
I have tried using ALTER TABLE commands but they don't seem to allow one
to make a change like this, so I resorted to a very tedious and slow
approach of
making a temporary table (same structure as the one in question, but with
the datatype
change), inserting all records into it, clearing out and dropping the
original table, creating
a new table (with the correct name, types etc), transferring the data back
into this one, and
finally dropping the temporary table.
Two problems with this approach are that it can be VERY slow on large
datasets (half a
million records) and it also seems to crash sometimes - for example, when I
want to drop
one of the tables, it says that the table doesn't exist. A restart of
IBOConsole allows it
to continue.
Thanks
Sandy
Does anyone know of a more efficient way to perform the following
alteration...
I have a table which is already full of data, and I want to change the
datatype
of one of its columns (this column that needs changing might be the primary
key).
I have tried using ALTER TABLE commands but they don't seem to allow one
to make a change like this, so I resorted to a very tedious and slow
approach of
making a temporary table (same structure as the one in question, but with
the datatype
change), inserting all records into it, clearing out and dropping the
original table, creating
a new table (with the correct name, types etc), transferring the data back
into this one, and
finally dropping the temporary table.
Two problems with this approach are that it can be VERY slow on large
datasets (half a
million records) and it also seems to crash sometimes - for example, when I
want to drop
one of the tables, it says that the table doesn't exist. A restart of
IBOConsole allows it
to continue.
Thanks
Sandy