RESTORE_SCHEMA_STATS

2023-12-25 08:49:42  Updated

The RESTORE_SCHEMA_STATS procedure restores schema-level historical statistics of the specified point in time.

Syntax

DBMS_STATS.RESTORE_SCHEMA_STATS(
  ownname                VARCHAR2,
  as_of_timestamp        TIMESTAMP WITH TIME ZONE,
  force                  BOOLEAN DEFAULT FALSE,
  no_invalidate          BOOLEAN DEFAULT FALSE);

Parameters

Parameter Description
ownname The name of the schema.
as_of_timestamp The timestamp to which statistics are restored.
force Specifies whether to restore statistics by force and ignore the lock. Default value: FALSE.
no_invalidate Specifies whether to refresh the plan cache during statistics collection. If you set the value to TRUE, the plan cache will not be refreshed during statistics collection.

Exceptions

Error code Description
ORA-20000 The object does not exist, or you do not have the required privileges.
ORA-20001 Values are invalid or inconsistent.
ORA-20006 The historical statistics are unavailable and cannot be restored.

Considerations

To call this procedure, you must be the owner of the table. If the object is in the sys tenant, you must be the owner of the table or have the SYSDBA privilege.

Examples

Restore the statistics of the specified point in time on the hr schema.

obclient [hr]> CALL DBMS_STATS.RESTORE_SCHEMA_STATS ('hr', '2021-09-26 19:02:12.675729');
Query OK, 0 rows affected

Contact Us