The LOCK_TABLE_STATS procedure locks statistics on a table.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
DBMS_STATS.LOCK_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
stattype VARCHAR2 DEFAULT 'ALL');
Parameters
| Parameter | Description |
|---|---|
| ownname | The username. If the username is set to NULL, the current logon username is used by default. |
| tabname | The name of the table. |
| stattype | The type of the statistics to be locked. Three types are supported:
'ALL' type. |
Considerations
To call this procedure, you must be the owner of the table. If the object is in the
systenant, you must be the owner of the table or have theSYSDBAprivilege.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.When you call the
EXPORT_*_STATSprocedure, the lock or unlock status is not exported with the table statistics.The
UNLOCK_SCHEMA_STATSandUNLOCK_TABLE_STATSprocedures 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-level 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
Lock the table-level statistics on the t1 table of the testUser01 user.
obclient> CALL DBMS_STATS.LOCK_TABLE_STATS ('testUser01', 't1');
Query OK, 0 rows affected