Reorganizing tables offline is the fastest way to defragment
your tables. Reorganization reduces the amount of space that is required
for a table and improves data access and query performance.
Before you begin
You must have SYSADM, SYSCTRL, SYSMAINT, DBADM, or SQLADM
authority, or CONTROL privilege on the table that is to be reorganized.
You must also have a database connection to reorganize a table.
About this task
After you have identified the tables that require reorganization,
you can run the reorg utility against those tables and, optionally,
against any indexes that are defined on those tables.
Procedure
- To reorganize a table using the REORG TABLE command,
simply specify the name of the table. For example:
reorg table employee
You
can reorganize a table using a specific temporary table space. For
example:
reorg table employee use mytemp
You
can reorganize a table and have the rows reordered according to a
specific index. For example:
reorg table employee index myindex
- To reorganize a table using an SQL CALL statement, specify
the REORG TABLE command with the ADMIN_CMD procedure.
For example:
call sysproc.admin_cmd ('reorg table employee')
- To reorganize a table using the administrative application
programming interface, call the db2Reorg API.
What to do next
After reorganizing a table, collect statistics on that table
so that the optimizer has the most accurate data for evaluating query
access plans.