The IMPORT_TABLE_STATS procedure is used to import table-level statistics.
Syntax
DBMS_STATS.IMPORT_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
stattab VARCHAR2,
cascade BOOLEAN DEFAULT TRUE,
statown VARCHAR2 DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT FALSE,
force BOOLEAN DEFAULT FALSE
);
Parameters
Parameter |
Explanation |
|---|---|
| ownname | Username. If the username is set to NULL, the current logged-in username will be used by default. |
| tabname | Table name. |
| partname | The name of the table partition. If the table is partitioned and partname is NULL, then import global and partition column statistics. |
| stattab | Specifies the name of the table that imports user statistics. |
| cascade | If it is TRUE, the column and index statistics of this table are also exported. |
| statown | Specifies the username for importing user statistics tables. |
| no_invalidate | Whether to flush the plan cache when statistics are collected. Valid values: TRUE Indicates that the plan cache is not flushed during statistics collection. |
| force | Whether to forcibly import the data and ignore the lock status. Default value: FALSE. If set to TRUE, the statistics will still be imported even if they are locked. |
Exceptions
Error Code |
Description |
|---|---|
| HY000 |
|
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.Exporting or importing statistics is not supported across databases with different character sets.
Examples
Import the statistics from table tbl1 of user testUser01 into table test_stat of user testUser02.
obclient> CALL DBMS_STATS.CREATE_STAT_TABLE('testUser02', 'test_stat');
Query OK, 0 rows affected
obclient> CALL DBMS_STATS.IMPORT_TABLE_STATS('testUser01', 'tbl1', stattab=>'test_stat', statown=>'testUser02');
Query OK, 0 rows affected