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 |
Explanation |
|---|---|
| ownname | Username. If the username is set to NULL, the current logged-in username will be used by default. |
| tabname | Table name. |
| partname | The name of the table partition. If the table is already partitioned and partname is NULL, global and partition column statistics are exported. |
| stattab | Specifies the table name of the user table for storing statistics. |
| cascade | Whether to export column-level statistics. Default is TRUE. |
| statown | Specifies the username of the user table for storing statistics. |
| stat_category | Note This parameter is not supported in the current version. |
Exceptions
Error code HY000 indicates that the object does not exist or you do not have sufficient privileges.
Usage instructions
To call this procedure, you must be the owner of the table. For objects owned by
SYS, you must be the table owner or have theSYSDBAprivilege to call this procedure.Exporting or importing statistics is not supported across databases with different character sets.
Examples
Create a statistics user table named
test_statfor the usertestUser02.obclient> CALL DBMS_STATS.CREATE_STAT_TABLE('testUser02', 'test_stat'); Query OK, 0 rows affectedExport the statistics of table
tbl1for usertestUser01totest_stat.obclient> CALL DBMS_STATS.EXPORT_TABLE_STATS('testUser01', 'tbl1', stattab=>'test_stat', statown=>'testUser02'); Query OK, 0 rows affected