Skip to main content

IMPORT_SCHEMA_STATS

The IMPORT_SCHEMA_STATS procedure is used to import statistics for all tables under a schema.

Syntax

DBMS_STATS.IMPORT_SCHEMA_STATS (
ownname VARCHAR2,
stattab VARCHAR2,
statown VARCHAR2 DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT FALSE,
force BOOLEAN DEFAULT FALSE
);

Parameters

ParameterDescription
ownnameThe name of the schema.
stattabThe name of the user table that stores statistics.
statownThe username of the user table that stores statistics.
no_invalidateSpecifies whether to invalidate the plan cache when collecting statistics. If set to TRUE, the plan cache will not be invalidated when collecting statistics.
forceSpecifies 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 CodeDescription
HY000
  • The object does not exist or the user does not have sufficient privileges.
  • The values in the user statistics table are invalid or inconsistent.

Usage Notes

  • You must be the owner of the table to call this procedure.

  • Statistics cannot be exported or imported between databases with different character sets.

Examples

Import statistics stored in the test_stat table for the testUser01 user in the hr schema into the dictionary.

CALL DBMS_STATS.IMPORT_SCHEMA_STATS(ownname=>'hr', stattab=>'test_stat', statown=>'testUser01');
Query OK, 0 rows affected