PROBLEM:

While importing a stats table in oracle 12c, for which the stats export was done from 11g , got below error. i.e both stats table was exported from a lower version and import attempt was done on higher version(12c).

 

SQL> exec dbms_stats.import_table_stats(ownname=>'RAJ', tabname=>'TEST',  stattab=>'STAT_TEST', cascade=>true);

ORA-20002: Version of statistics table SCOTT.STATS is too old. Please try upgrading it with dbms_stats.upgrade_stat_table
ORA-06512: at "SYS.DBMS_STATS", line 11476
ORA-06512: at "SYS.DBMS_STATS", line 11493
ORA-06512: at "SYS.DBMS_S>TATS", line 12628
ORA-06512: at line 1

SOLUTION:

If we are importing stats table from higher version to lower version, then before importing in the database, we need to upgrade the stats table.

UPGRADE STATS TABLE:

SQL> EXECUTE DBMS_STATS.UPGRADE_STAT_TABLE('RAJ','STAT_TEST');

PL/SQL procedure successfully completed.

Now do the import:

 exec dbms_stats.import_table_stats(ownname=>'RAJ', tabname=>'TEST',  stattab=>'STAT_TEST', cascade=>true);

PL/SQL procedure successfully completed.