The LOCK_SCHEMA_STATS procedure is used to lock the statistics of all tables in a schema.
Syntax
DBMS_STATS.LOCK_SCHEMA_STATS(
ownname VARCHAR2,
stattype VARCHAR2 DEFAULT 'ALL');
Parameters
Parameter |
Explanation |
|---|---|
| ownname | The name of the schema. |
| stattype | The type of lock. Generally, there are the following three types:
|
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 cause an error.When using the
EXPORT_*_STATSprocedure, the lock or unlock status is not exported together with 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, which prevents you from collecting 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 statistics of all tables in the hr schema.
obclient> CALL DBMS_STATS.LOCK_SCHEMA_STATS(ownname=>'hr', stattype=>'ALL');
Query OK, 0 rows affected