The SET_TABLE_STATS procedure sets table-level basic statistics information.
Syntax
DBMS_STATS.SET_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
numrows NUMBER DEFAULT NULL,
numblks NUMBER DEFAULT NULL,
avgrlen 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. |
| 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. |
| numrows | The total number of rows at the table level. |
| numblks | The number of blocks that the table occupies. |
| avgrlen | 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
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.The optimizer estimates the number of cached blocks accessed by an index or a statistics table based on the cached data. The total costs of the operation consist of the I/O cost of reading uncached blocks from the disk, CPU cost of fetching cached blocks from the buffer cache, and CPU cost of processing data.
Examples
Set the total number of rows to 10,000 for the tbl1 table of the testUser01 user.
obclient> CALL DBMS_STATS.SET_TABLE_STATS('testUser01', 'tbl1', numrows=>10000, force=>FALSE, no_invalidate=>FALSE);
Query OK, 0 rows affected