Rebuilding a table

Use reorg rebuild when:

If a table needs to be rebuilt because of a low cluster ratio, it may also need to have its space management settings changed (see “Changing space management settings before using reorg rebuild”).

If reorg rebuild finds that the current table is used by another session, it does not wait for this session to end. Instead, it aborts the entire transaction.

reorg rebuild uses a table’s current space management settings to rewrite the rows in the table according to the table’s clustered index, if it has one. All indexes on the table are dropped and re-created using the current space management values for reservepagegap and fillfactor. After a rebuild, a table has no forwarded rows and no unused space from deletions or updates.

reorg rebuild syntax

The syntax for reorg rebuild is:

reorg rebuild table_name [index_name [partition index_partition_name]

reorg rebuild performs the following when you run it against a table and a partition:

If the table is large and has several indexes, the locks for updating system tables can be held for a long time and can block processes from accessing information in the system tables for the user tables on which you are running reorg. However, because systabstats is already datarow-locked, this system table does not impact this blocking.

reorg rebuild builds the clustered index using the with sorted data option, so the data does not have to be re-sorted during this index build.