I am trying to follow
these steps in 12.1.0.2 and it fails when I run the step 3 (export
stats). This works well in 11g.
BEGIN
dbms_stats.Create_stat_table(user, 'MY_STATS_TAB');
END;
exec dbms_stats.upgrade_stat_table(user, 'MY_STATS_TAB')
BEGIN
DBMS_STATS.Export_table_stats (USER,
stattab => 'MY_STATS_TAB',
tabname => 'MD_TABLE_INFO',
statid => '11g_stats');
END;
ORA-20002: Version of statistics table "wwfuser"."MY_STATS_TAB" is too old.
Please try upgrading it with dbms_stats.upgrade_stat_table
ORA-06512: at "SYS.DBMS_STATS", line 18000
ORA-06512: at line 2
On further research we
found that this issue occurs when database NLS_LENGTH_SEMANTICS are set to
CHAR. By default we have CHAR settings in place of BYTE.
This is oracle bug 18459892
that fixed in 12.2.
After changing NLS_LENGTH_SEMANTICS
it worked fine.
exec dbms_stats.drop_stat_table(ownname => 'WWFUSER', stattab => 'MY_STATS_TAB');
ALTER SESSION SET NLS_LENGTH_SEMANTICS = BYTE
exec dbms_stats.create_stat_table(ownname => 'WWFUSER', stattab => 'MY_STATS_TAB');
EXEC dbms_stats.export_table_stats(ownname => 'WWFUSER',tabname => 'MD_TABLE_INFO',stattab => 'MY_STATS_TAB',statid => 'Q21212');
Another alternative is
to create stats table in SYS schema or with BYTE character set.
by SYS user:
EXEC
dbms_stats.create_stat_table(ownname => 'SYS',stattab =>
'STATTAB',tblspace => 'WWFDATA');
grant all on STATTAB TO
wwfmgr;
then by wwf user:
EXEC
dbms_stats.export_table_stats(ownname => 'WWFUSER',tabname =>
'MD_TABLE_INFO',stattab => 'STATTAB',statid => 'Q21212',statown =>
'SYS');
Hope it helps.
No comments:
Post a Comment