The LOCK_TABLE_STATS procedure is used to lock table statistics.
Syntax
DBMS_STATS.LOCK_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
stattype VARCHAR2 DEFAULT 'ALL');
Parameters
Parameter |
Explanation |
|---|---|
| ownname | Username. If the username is set to NULL, the current login username will be used by default. |
| tabname | Table name. |
| stattype | The type of lock. Generally, the following three lock types are supported:
|
Usage instructions
To call this procedure, you must be the owner of the table. For objects owned by
SYS, you must be the table owner or have theSYSDBAprivilege to call this procedure.When the statistics of a table are locked, all statistics that depend on it are locked, including table-level statistics, column-level statistics, histogram statistics, and all index-dependent statistics.
If the statistics of an object are locked, executing the
SET_*, DELETE_*, IMPORT_*, or GATHER_*procedure to modify the statistics of a single table, index, or column will raise an error.When you call the
EXPORT_*_STATSprocedure, the lock or unlock status is not exported together with the table-level statistics.Neither the
UNLOCK_SCHEMA_STATSnor theUNLOCK_TABLE_STATSprocedure can unlock statistics for the corresponding partition. When you call theLOCK_TABLE_STATSprocedure, it sets a lock at the table level. In this case, you cannot collect statistics on dependent objects such as partitions and indexes. Furthermore, if table-level statistics are locked, their dependencies are also locked, so there is no need to explicitly call theLOCK_PARTITION_STATSprocedure to lock partition statistics.
Examples
Lock the table-level statistics of table t1 under user testUser01.
obclient> CALL DBMS_STATS.LOCK_TABLE_STATS ('testUser01', 't1');
Query OK, 0 rows affected