Skip to main content
Version: V1.0.0

LOCK_TABLE_STATS

The LOCK_TABLE_STATS procedure is used to lock the statistics of a table.

Syntax

DBMS_STATS.LOCK_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
stattype VARCHAR2 DEFAULT 'ALL');

Parameters

ParameterDescription
ownnameThe username. If the username is set to NULL, the current login username is used by default.
tabnameThe name of the table.
stattypeThe type of lock. The following three types of locks are generally supported:
  • 'ALL'
  • 'DATA'
  • 'CACHE'

Usage notes

  • You must be the owner of the table to call this procedure.

  • When the statistics of a table are locked, the statistics of all dependent objects, including table-level statistics, column-level statistics, histogram statistics, and all index-dependent statistics, are also locked.

  • If the statistics of an object are locked, an error will be returned when you execute the SET_*, DELETE_*, IMPORT_*, or GATHER_* procedure to modify the statistics of a single table, index, or column.

  • When you call the EXPORT_*_STATS procedure, the lock or unlock status is not exported along with the table-level statistics.

  • The UNLOCK_SCHEMA_STATS and UNLOCK_TABLE_STATS procedures cannot unlock the statistics of corresponding partitions. When you call the LOCK_TABLE_STATS procedure, it sets the lock at the table level. At this point, you cannot collect statistics on dependent objects such as partitions and indexes. In addition, if the table-level statistics are locked, their dependent items are also locked, so you do not need to explicitly call the LOCK_PARTITION_STATS procedure to lock the partition statistics.

Examples

Lock the table-level statistics of the t1 table under the testUser01 user.

CALL DBMS_STATS.LOCK_TABLE_STATS ('testUser01', 't1');
Query OK, 0 rows affected