The RESTORE_TABLE_STATS procedure is used to restore table-level historical statistics at a specified point in time.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
DBMS_STATS.RESTORE_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
as_of_timestamp TIMESTAMP WITH TIME ZONE,
force BOOLEAN DEFAULT FALSE,
no_invalidate BOOLEAN DEFAULT FALSE);
Parameters
| Parameter | Description |
|---|---|
| ownname | The username. If the username is set to NULL, the current login username will be used by default. |
| tabname | The table name. |
| as_of_timestamp | The timestamp to restore. |
| force | Whether to forcibly restore and ignore locks. The default value is FALSE. |
| no_invalidate | Whether to clear the plan cache when collecting statistics. If set to TRUE, the plan cache will not be cleared when collecting statistics. |
Exceptions
| Error code | Description |
|---|---|
| OBE-20000 | The object does not exist or the user does not have sufficient privileges. |
| OBE-20001 | Invalid or inconsistent value. |
| OBE-20006 | The statistics cannot be restored because the statistics history is unavailable. |
Considerations
To call this procedure, you must be the owner of the table. For objects owned by SYS, you must be the owner of the table or have the SYSDBA privilege to call this procedure.
Examples
Restore the statistics of the tbl1 table under the testUser01 user at a specified point in time.
obclient> CALL DBMS_STATS.RESTORE_TABLE_STATS ('testUser01', 'tbl1',TO_TIMESTAMP('2022-12-06 22:00:01.007146', 'YYYY-MM-DD HH24:MI:SS.FF'));
Query OK, 0 rows affected
