The IMPORT_SCHEMA_STATS procedure is used to import statistics for all tables under a schema.
Syntax
DBMS_STATS.IMPORT_SCHEMA_STATS (
ownname VARCHAR2,
stattab VARCHAR2,
statown VARCHAR2 DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT FALSE,
force BOOLEAN DEFAULT FALSE
);
Parameters
| Parameter | Description |
|---|---|
| ownname | The name of the schema. |
| stattab | The name of the user statistics table to import statistics from. |
| statown | The username of the user statistics table to import statistics from. |
| no_invalidate | Whether to invalidate the plan cache when collecting statistics. Set to TRUE to not invalidate the plan cache when collecting statistics. |
| 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
You must be the owner of the table to call this procedure. For
SYS-owned objects, you must be the owner or have theSYSDBAprivilege to call this procedure.Statistics cannot be exported or imported between databases with different character sets.
Examples
Import the statistics stored in the test_stat table for the user testUser01 in the hr schema into the dictionary.
obclient> CALL DBMS_STATS.IMPORT_SCHEMA_STATS(ownname=>'hr', stattab=>'test_stat', statown=>'testUser01');
Query OK, 0 rows affected
