Wednesday 12 December 2012

Move indexes from one Tablespace to another Tablespace

Method 1:


Select ' ALTER INDEX ' || owner || '.'||INDEX_NAME ||' rebuild tablespace [
 new_tablespace_name];' from DBA_indexes
 where index_name in ( select segment_name from
 dba_segments where tablespace_name='USERS')

Method 2:


declare


type vt is table of varchar2(64);
l_in vt;
begin
-- fetching all names to avoid ORA-01555
select index_name 
bulk collect into l_in
from dba_indexes where tablespace_name='<current index tablespace>';

for i in 1..l_in.count loop
execute immediate 'alter index '||l_in(i)||' rebuild tablespace <new index tablespace>';
end loop;
end;
/

Thursday 6 December 2012

"EXP-00091 Exporting questionable statistics" Error


The "EXP-00091 Exporting questionable statistics" error happens when you export table data with its related optimizer statistics, and Oracle cannot verify the currency of these statistics.  When CBO statistics are created/updated with dbms_stats, the time is noted, but it’s always a good idea not to export statistics since they should be recalculated after import.
You can remove the EXP-00091 error by exporting with "statistics="none" or by setting the client character set

(e.g. export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1).

The Oracle docs note this on the EXP-00091 error:
EXP-00091 Exporting questionable statistics

Cause: Export was able to export statistics, but the statistics may not be usable  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 sub partitions 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, or 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.