The UNLOCK_SCHEMA_STATS procedure is used to unlock the statistics of all tables in a schema.
Syntax
DBMS_STATS.UNLOCK_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_, orGATHER_procedure to modify the statistics of a single table, index, or column will cause an error.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 statistics are locked, their dependencies are also locked, so there is no need to explicitly call theLOCK_PARTITION_STATSprocedure to lock partition statistics.
Examples
Unlock the statistics for all tables in the hr schema.
obclient [test]> USE hr;
Database changed
obclient [hr]> CALL DBMS_STATS.UNLOCK_SCHEMA_STATS ('hr', stattype=>'ALL');
Query OK, 0 rows affected