The IMPORT_SCHEMA_STATS procedure is used to import statistics for all tables under a specified user.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
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 username. If the username is set to NULL, the current login username is used by default. |
| stattab | The name of the table that stores the statistics to be imported. |
| statown | The username of the user whose statistics are to be imported. |
| no_invalidate | Specifies whether to clear the plan cache when collecting statistics. If set to TRUE, the plan cache will not be cleared when collecting statistics. |
| force | Specifies whether to forcibly import statistics and ignore lock status. The default value is FALSE. If set to TRUE, statistics will be imported even if they are locked. |
Exceptions
| Error code | Description |
|---|---|
| OBE-20000 | The object does not exist or the user does not have sufficient privileges. |
| OBE-20001 | The values in the user statistics table are invalid or inconsistent. |
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 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 under the hr user into the dictionary of the testUser01 user.
obclient> CALL DBMS_STATS.IMPORT_SCHEMA_STATS(ownname=>'hr', stattab=>'test_stat', statown=>'testUser01');
Query OK, 0 rows affected
