The SET_COLUMN_STATS procedure sets column-level basic statistics information.
Syntax
DBMS_STATS.SET_COLUMN_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
colname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
distcnt NUMBER DEFAULT NULL,
density NUMBER DEFAULT NULL,
nullcnt NUMBER DEFAULT NULL,
avgclen NUMBER DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT FALSE,
force BOOLEAN DEFAULT FALSE);
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 to which the column belongs. |
| colname | The column name or the extension name. |
| partname | The name of the table partition that stores the statistics. If the table is partitioned and partname is NULL, statistics are stored at the table level. |
| distcnt | The number of distinct values (NDV) value at the column level. |
| density | The density at the column level. If this parameter is NULL and distcnt is not NULL, the value of distcnt is taken as the density. |
| nullcnt | The number of NULL values at the column level. |
| avgclen | The average column length, in bytes. |
| no_invalidate | Specifies whether to refresh the plan cache when statistics are collected. If you set the value to TRUE, the plan cache will not be refreshed during statistics collection. |
| force | Specifies whether to perform forced collection and ignore the lock status. Default value: FALSE. If you set the value to TRUE, statistics will be collected even if they are locked. |
Exceptions
| Error code | Description |
|---|---|
| HY000 |
|
Considerations
In the current version of OceanBase Database, the statistics type specified by users in SET_COLUMN_STATS must be stored in the dictionary. If the statistics type is NULL, the statistics type associated with the index or column is stored.
To call this procedure, you must be the owner of the table. If the object is in the sys tenant, you must be the owner of the table or have the SYSDBA privilege.
Examples
For the col1 column in the tbl1 table of the testUser01 user, set the NDV value to 10 and the number of NULL values to 10.
obclient> CALL DBMS_STATS.SET_COLUMN_STATS('testUser01', 'tbl1', 'col1', distcnt=>10, nullcnt=>10);
Query OK, 0 rows affected