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 | Description |
|---|---|
| ownname | The username. If the username is set to NULL, the current logged-in username will be used by default. |
| tabname | The table name. |
| partname | The name of the table partition. If the table is partitioned and partname is NULL, global and partition column statistics will be imported. |
| stattab | The name of the user statistics table to be imported. |
| cascade | If TRUE, column and index statistics for this table will also be imported. |
| statown | The username of the user statistics table to be imported. |
| no_invalidate | Specifies whether to invalidate the Plan Cache when collecting statistics. Set to TRUE to avoid invalidating the Plan Cache. |
| force | Whether to forcibly import statistics and ignore lock status. Default is FALSE. If set to TRUE, statistics will be imported even if they are locked. |
Exceptions
| Error Code | Description |
|---|---|
| HY000 |
|
Considerations
To call this procedure, you must be the owner of the table. For objects owned by
SYS, you must be the owner or have theSYSDBAprivilege.Statistics cannot be exported or imported between databases with different character sets.
Examples
Import statistics from the tbl1 table of user testUser01 into the test_stat table 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
