Monday, September 1, 2014

ORA-20005: object statistics are locked (stattype = ALL)

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(USER,'NUMBER_ARITHMETIC');
BEGIN DBMS_STATS.GATHER_TABLE_STATS(USER,'NUMBER_ARITHMETIC'); END;

*
ERROR at line 1:
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at "SYS.DBMS_STATS", line 20337
ORA-06512: at "SYS.DBMS_STATS", line 20360
ORA-06512: at line 1

SQL>

Cause:- Object statistic has been locked. 

Action: - First find object which object statistic locked and then unlock this object using DBMS_STATS package.


SQL> SELECT OWNER, TABLE_NAME, STATTYPE_LOCKED FROM DBA_TAB_STATISTICS WHERE OWNER=USER AND STATTYPE_LOCKED IS NOT NULL;

OWNER                          TABLE_NAME                     STATT
------------------------------ ------------------------------ -----
RND                            NUMBER_ARITHMETIC              ALL

SQL>


SQL> EXEC DBMS_STATS.UNLOCK_TABLE_STATS(USER,'NUMBER_ARITHMETIC');

PL/SQL procedure successfully completed.

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(USER,'NUMBER_ARITHMETIC');

PL/SQL procedure successfully completed.

SQL>



No comments:

Post a Comment