Locking and oncheck

The oncheck utility places a shared lock on a table, so no other users can perform updates, inserts, or deletes until the check has completed.

The oncheck utility places a shared lock on a table during the following operations:
  • When it checks data
  • When it checks indexes (with -ci, -cI, -pk, -pK, -pl, or -pL) and the table uses page locking
  • When you specify the -x option with -ci, -cI, -pk, -pK, -pl, or -pL and the table uses row locking

If the table does not use page locking, the database server does not place a shared lock on the table when you check an index with the oncheck -ci, -cI, -pk, -pK, -pl, or -pL options. When no shared lock is on the table during an index check, other users can update rows during the check.

By not placing a shared lock on tables using row locks during index checks, the oncheck utility cannot be as accurate in the index check. For absolute assurance of a complete index check, you can execute oncheck with the -x option. With the -x option, oncheck places a shared lock on the table, and no other users can perform updates, inserts, or deletes until the check has completed.

The oncheck utility returns unreliable results when run on secondary servers in a high-availability cluster.

For more information about the -x option, refer to Turn On Locking with -x. For information on shared locks and intent shared locks, see the HCL OneDB™ Performance Guide.

The oncheck utility places a shared lock on system catalog tables when they are checked. It places an exclusive lock on a table when it executes repair options.