Search Blog Post

Thursday, May 16, 2013

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

Today I analyze a table and get the error messages below

ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at “SYS.DBMS_STATS”, line 23829
ORA-06512: at “SYS.DBMS_STATS”, line 23880
ORA-06512: at line 2


Solution:
You can see list of all locked tables in a schema by running following query:

select table_name, stattype_locked from dba_tab_statistics where owner = ‘<schema>’ and stattype_locked is not null;

You can unlock the schema stats:
exec dbms_stats.unlock_schema_stats('<shema_name>');

Or unlock the table stats:
SQL> exec DBMS_STATS.UNLOCK_TABLE_STATS('SYSTEM', 'DEF$_AQERROR');

PL/SQL procedure successfully completed.

And the stats can be collected:
SQL> exec dbms_stats.unlock_schema_stats('<shema_name>');

PL/SQL procedure successfully completed.

SQL> exec dbms_stats.gather_table_stats(ownname=>'cisadm',tabname=>'c0_installation',ESTIMATE_PERCENT => 30);

PL/SQL procedure successfully completed. 


To generate unlock statement for all tables in the schema you can use following,
select ‘exec DBMS_STATS.UNLOCK_TABLE_STATS (”’|| owner ||”’,”’|| table_name ||”’);’ from dba_tab_statistics where owner = ‘<schema>” and stattype_locked is not null;


No comments:

Post a Comment