The EXPORT_TABLE_STATS procedure is used to export table-level statistics.
Syntax
DBMS_STATS.EXPORT_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
stattab VARCHAR2,
cascade BOOLEAN DEFAULT TRUE,
statown VARCHAR2 DEFAULT NULL,
stat_category VARCHAR2 DEFAULT DEFAULT_STAT_CATEGORY);
Parameters
| Parameter | Description |
|---|---|
| ownname | The username. If ownname is set to NULL, the current login username is used by default. |
| tabname | The table name. |
| partname | The name of the table partition. If the table is partitioned and partname is NULL, global and partition column statistics are exported. |
| stattab | The name of the user table that stores the statistics. |
| cascade | Whether to export column-level statistics. The default value is TRUE. |
| statown | The username of the user who owns the user table that stores the statistics. |
| stat_category | Description This parameter is not supported in the current version. |
Exceptions
The error code HY000 indicates that the object does not exist or that the user does not have sufficient privileges.
Considerations
To call this procedure, you must be the owner of the table. For objects owned by
SYS, you must be the owner or have theSYSDBAprivilege.Statistics cannot be exported or imported between databases with different character sets.
Examples
Create a statistics user table
test_statfor usertestUser02.obclient> CALL DBMS_STATS.CREATE_STAT_TABLE('testUser02', 'test_stat'); Query OK, 0 rows affectedExport the statistics of the
tbl1table for usertestUser01totest_stat.obclient> CALL DBMS_STATS.EXPORT_TABLE_STATS('testUser01', 'tbl1', stattab=>'test_stat', statown=>'testUser02'); Query OK, 0 rows affected
