The IMPORT_INDEX_STATS procedure retrieves the statistics of a specified index from user information statistics tables and stores them in the dictionary.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
DBMS_STATS.IMPORT_INDEX_STATS (
ownname VARCHAR2,
indname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
stattab VARCHAR2,
statown VARCHAR2 DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT FALSE,
force BOOLEAN DEFAULT FALSE,
tabname VARCHAR2 DEFAULT NULL);
Parameters
| Parameter | Description |
|---|---|
| ownname | Username. If ownname is set to NULL, the username that is logged in currently will be used by default. |
| tabname | Table name. |
| indname | Index name. |
| partname | Partition name. If the table is partitioned and partname is set to NULL, statistics of global and partitioned columns will be imported. |
| stattab | The name of the user statistics table to be imported. |
| statown | The username of the user statistics table to be imported. |
| no_invalidate | Specifies whether to invalidate the plan cache during statistics collection. If set to TRUE, the plan cache will not be invalidated during statistics collection. |
| force | Specifies whether to import statistics regardless of the lock status. The default value is FALSE. If set to TRUE, statistics will be imported even if they are locked. |
Error codes
| Error code | Description |
|---|---|
| ORA-20000 | The object does not exist or you have insufficient privileges. |
| ORA-20001 | The values in the user information statistics table are invalid or inconsistent. |
| ORA-20005 | The statistics of the object are locked. |
Considerations
Statistics cannot be exported or imported between columns of different character sets.
Example
Import and store the statistics of the idx1 index on the tbl1 table in the test_stat user database to the dictionary.
obclient> CALL DBMS_STATS.IMPORT_INDEX_STATS('testUser01', 'idx1',stattab=>'test_stat', 'tbl1');
Query OK, 0 rows affected
Note
In the Oracle mode of OceanBase Database, you do not need to specify tabname. This is because indexes are unique within the current user. In the MySQL mode, you must explicitly specify the table name because indexes are non-unique within the current user.