How do add primary key contraint on existing table?
Posted in 1997
Topics: Storage & Space Management, Error Codes & Troubleshooting, Migration, Import/Export & Data Conversion
Hello all,
I have to periodically purge data from an approximately 7 million row
table. Btw, I am running Informix OnLine 7.20 on a DEC Alpha Unix 3.20G
with 128 MB. The table is fragmented over two dbspaces. I am doing the
purge by unloading all data except that which I want to exclude, then
using dbload utility to reload the data after dropping the table. Prior
to dropping the table, I run the dbschema utility with server specific
syntax so I can recreate the table. The table has two not null
constraints on it along with a primary key constraint. I have found that
I can load 40,000 records per minute without the primary key, and 5000
records/min with the primary key constraint. That works out to 3 hours
vs 29 hours. I tried to use the ALTER TABLE command (without specifying
the dbspace) to add the primary key constraint after loading the data,
but I get an ISAM error message that says it has run out of disk space.
My question is this: does the ALTER TABLE command try to create a new
table in the same dbspace (and then copy records from old to new and
then drop old table)? If so, it would definitely run out of space; what
syntax would I use to specify that I want to add the contraint in-place?
If not, where is the system trying to add the constraint, and how can I
get it on there without running out of space?
Any help would be greatly appreciated...
John Graffio Systems Manager, CPTC
(714) 637-9191 x202