Wednesday, April 05, 2006

Oracle EXP-00091, Exporting Questionable Statistics

When performing an Oracle export, you may receive error, "EXP-00091: Exporting questionable statistics."

The first thing to do is gather a little more information with "oerr" on the command line:
$ oerr exp 91
00091, 00000, "Exporting questionable statistics."
// *Cause: Export was able export statistics, but the statistics may not be
// usuable. The statistics are questionable because one or more of
// the following happened during export: a row error occurred, client
// character set or NCHARSET does not match with the server, a query
// clause was specified on export, only certain partitions or
// subpartitions were exported, or a fatal error occurred while
// processing a table.
// *Action: To export non-questionable statistics, change the client character
// set or NCHARSET to match the server, export with no query clause,
// export complete tables. If desired, import parameters can be
// supplied so that only non-questionable statistics will be imported,
// and all questionable statistics will be recalculated.

Then search Oracle's documentation:
The precalculated optimizer statistics are flagged as questionable at export
time if:
* There are row errors while exporting
* The client character set or NCHAR character set does not match the server character set or NCHAR character set
* A QUERY clause is specified
* Only certain partitions or subpartitions are exported

The NCHAR setting often causes this message, and the message will often be avoided by setting the NLS_LANG environment variable to match the database setting.

Questionable statistics are ususally a minor inconvenience, because after the import it is easy to re-analyze. Additionally, you may set "statistics=safe" on the import to skip importing questionable statistics.

Oracle Role Insufficient For User's Procedure To Compile

Roles are useful, though there are a few limitations. This is one limitation of Oracle roles.

Table owned by userA. UserB has "select any table" and creates SQL that sucessfully runs in sql*plus. When userB tries to put the SQL in a package, there is ORA-00942 compile error.
The solution is to directly grant the userA.table_name SELECT privilege to userB. It's not enough to have a role that allows the SELECT permission.

Example:
Create package header with no problems, then try to create package body:

Warning: Package Body created with compilation errors.

SQL> show err
Errors for PACKAGE BODY xPKG:

LINE/COL ERROR
--------
-----------------------------------------------------------------
27/7 PL/SQL: SQL Statement ignored
72/29 PL/SQL: ORA-00942: table or view does not exist

-- In another session, directly grant SELECT on table_name to this user.

-- In this session, re-submit package body.

SQL> /
Package body created.

Sunday, March 26, 2006

Move Oracle Indexes To Another Tablespace

Some (mostly old-school) Oracle DBAs like to move indexes into a tablespace other than the tablespace(s) for tables. Moving an index does rebuild the index, for the limited cases when an index rebuild is a good thing.
This SQL will generate the SQL to move indexes.

select 'alter index ' || owner || '.' || index_name || ' rebuild
tablespace &newTablespace'
from sys.dba_indexes
where owner = '&ownerName'
/