The EXPORT_TABLE_STATS procedure exports 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 the username is set to NULL, the current logon username is used by default. |
| tabname | The name of the table. |
| partname | The name of the table partition. If the table is partitioned and partname is NULL, global statistics and partition column statistics are exported. |
| stattab | The name of the user statistics table for storing statistics. |
| cascade | Specifies whether to export column-level statistics. Default value: TRUE. |
| statown | The username of the user statistics table for storing statistics. |
| stat_category | Note: The current version does not support this parameter. |
Exceptions
The error code ORA-20000 indicates that the object does not exist, or you do not have the required privileges.
Considerations
To call this procedure, you must be the owner of the table. If the object is in the
systenant, you must be the owner of the table or have theSYSDBAprivilege.You cannot export or import statistics across databases that use different character sets.
Examples
Create the statistics table
test_statof thetestUser02user.obclient> CALL DBMS_STATS.CREATE_STAT_TABLE('testUser02', 'test_stat'); Query OK, 0 rows affectedExport the statistics on the
tbl1table of thetestUser01user to thetest_stattable.obclient> CALL DBMS_STATS.EXPORT_TABLE_STATS('testUser01', 'tbl1', stattab=>'test_stat', statown=>'testUser02'); Query OK, 0 rows affected