Upgrading DB2 databases

Prior to NexJ Contact version 5.1, indexes marked as clustered were generated as non-clustered for IBM DB2 databases. Starting with NexJ Contact version 5.1, these indexes are recognized as clustered and commands generated in NexJ Studio are interpreted correctly.

However, if an index was originally created as non-clustered, subsequent commands against that index may fail.

Before you begin upgrading NexJ Contact and using upgrade scripts generated by NexJ Studio, ensure that the indexes in your databases are clustered as defined by your model.

To determine which indexes should have been created as clustered, do one of the following for your current model:
  • Using NexJ Studio, in the Persistence layer, review the table index information for the database.
  • Using the Database Schema Tool in NexJ Studio, generate the create command SQL script for your database. Review the script to find instances of the word "clustered" in CREATE INDEX statements.
To ensure that any future commands affecting DB2 database tables with clustered primary keys are compatible with DB2 tables created prior to NexJ Contact version 5.1, issue the following commands against your DB2 database.
  1. Drop the primary key constraints.
    Issue an ALTER TABLE statement with the DROP CONSTRAINT clause. For example:
    alter table nexj.NJSyncLinkClass drop
            constraint NJSyncLinkClass_PK
  2. Recreate the dropped indexes.
    Issue a CREATE INDEX statement with the CLUSTER clause. For example:
    create unique index nexj.NJSyncLinkClass_PK on
            nexj.NJSyncLinkClass(linkId, classId) cluster allow reverse
            scans
  3. Add the primary key constraints back to the table.
    Issue an ALTER TABLE statement with the ADD CONSTRAINT clause. For example:
    alter table nexj.NJSyncLinkClass add
            constraint NJSyncLinkClass_PK primary key(linkId,
            classId)
The primary index keys for the table are now clustered and will not cause errors in any future SQL statements issued against the table.