Thread: Reorg Table - how about PK?
12-02-04, 16:37 #1Registered User
- Join Date
- Sep 2002
Unanswered: Reorg Table - how about PK?
DB2 V7 FP6 on AIX 4.3.3
If I reorg a table with:
db2 reorg table mytable index myindex use tbsz;
will it also reorg the index myindex? Or just reorg the table data in the order of index myindex?
If the statement above will not reorg the index, then how about these steps:
1. Drop myindex
2. Recreate myindex
3. Reorg table mytable with index myindex
Now, I should have table data in the same order as index....!
12-02-04, 23:27 #2Registered User
- Join Date
- May 2003
In version 7, the indexes will be reorged along with the table. In version 8, there is a separate command to reorg indexes.
When you chose an index to reorg the tables with, DB2 uses the index columns to order the table rows. If you PK has only one column, then that is "probably" the wrong sequence to order the table rows (assuming that you have other indexes on the table).
Generally speaking, one index should be defined as the clustering index, so that inserts will maintain (if possible) the correct sequence of the data, in addition to when you do a reorg of the table.M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390