Skip to main content

IMPORT_TABLE_STATS

The IMPORT_TABLE_STATS procedure is used to import table-level statistics.

Syntax

DBMS_STATS.IMPORT_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
stattab VARCHAR2,
cascade BOOLEAN DEFAULT TRUE,
statown VARCHAR2 DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT FALSE,
force BOOLEAN DEFAULT FALSE
);

Parameters

ParameterDescription
ownnameThe username. If ownname is set to NULL, the current login username is used.
tabnameThe table name.
partnameThe name of the table partition. If the table is partitioned and partname is NULL, the global and partition column statistics are imported.
stattabThe name of the user statistics table to be imported.
cascadeIf TRUE, the column and index statistics of this table are also exported.
statownThe username of the user statistics table to be imported.
no_invalidateSpecifies whether to clear the Plan Cache when collecting statistics. If set to TRUE, the Plan Cache is not cleared when collecting statistics.
forceSpecifies whether to forcibly import the statistics and ignore the lock status. The default value is FALSE. If set to TRUE, the statistics are 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 from the test_stat table of user testUser02 to the tbl1 table of user testUser01.

CALL DBMS_STATS.CREATE_STAT_TABLE('testUser02', 'test_stat');
Query OK, 0 rows affected

CALL DBMS_STATS.IMPORT_TABLE_STATS('testUser01', 'tbl1', stattab=>'test_stat', statown=>'testUser02');
Query OK, 0 rows affected