Reorganizing tables online

An online or inplace table reorganization allows users to access a table while it is being reorganized.

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 online using the REORG TABLE command, specify the name of the table and the INPLACE parameter.
    For example:
       reorg table employee inplace
  • To reorganize a table online using an SQL CALL statement, specify the REORG TABLE command with the ADMIN_CMD procedure.
    For example:
       call sysproc.admin_cmd ('reorg table employee inplace')
  • To reorganize a table online 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.