The UNLOCK_SCHEMA_STATS procedure unlocks the statistics on all tables of the specified user.
Syntax
DBMS_STATS.UNLOCK_SCHEMA_STATS (
ownname VARCHAR2,
stattype VARCHAR2 DEFAULT 'ALL');
Parameters
| Parameter | Description |
|---|---|
| ownname | The name of the schema. |
| stattype | The type of the statistics to be locked. Three types are supported:
'ALL' type. |
Usage notes
To call this procedure, you must be the owner of the table or have the
ANALYZE ANYprivilege. If the object is in thesystenant, you must be the owner of the table or have theANALYZE ANY DICTIONARYorSYSDBAprivilege.When statistics on a table are locked, all statistics dependent on the table are locked, including table-level statistics, column-level statistics, histogram statistics, and statistics on all dependent indexes.
If the statistics on an object are locked, an error occurs when you execute a
SET_*,DELETE_*,IMPORT_*, orGATHER_*procedure to modify the statistics on a single table, index, or column.The
UNLOCK_SCHEMA_STATSorUNLOCK_TABLE_STATSprocedure cannot unlock the statistics on corresponding partitions. When you call theLOCK_TABLE_STATSprocedure, it sets a table-level lock position. In this case, you cannot collect statistics on dependent objects such as partitions and indexes. In addition, if table statistics are locked, the dependent objects are also locked. In this case, you do not need to explicitly call theLOCK_PARTITION_STATSprocedure to lock partition statistics.
Examples
Unlock the statistics on all tables in the hr schema.
obclient> CREATE USER hr IDENTIFIED BY 123456;
Query OK, 0 rows affected
obclient> CALL DBMS_STATS.UNLOCK_SCHEMA_STATS ('hr', stattype=>'ALL');
Query OK, 0 rows affected