The IMPORT_INDEX_STATS procedure retrieves the statistics of a specified index from user information statistics tables and stores them in the system 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 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 all partitions and 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. Set it to TRUE to specify not to invalidate the plan cache during statistics collection. |
| force | Specifies whether to import statistics forcefully, ignoring lock status. The default value is FALSE. If set to TRUE, statistics will be imported even if they are locked. |
Exceptions
| 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. |
Remarks
Statistics cannot be exported or imported between tables with different character sets.
Example
Import the statistics of the idx1 index from the tbl1 table of the testUser01 user in the test_stat table and store them in the system 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 the tabname parameter, because indexes are unique within the current user. In the MySQL mode, you need to specify the table name because indexes are non-unique within the current user.