ORA-20005 Estadisticas bloqueadas.

El error ORA-20005 significa que las estadísticas fueron bloqueadas y estas tratando de colectarlas

BEGIN 
dbms_stats.gather_table_stats(ownname=> 'ESQUEMA', tabname=> 'TABLE_TEST',Degree=> 8, cascade=>false, estimate_percent=> DBMS_STATS.auto_sample_size); 
END;
/

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

Verificamos que las estadísticas están bloqueadas.
col owner for a24
col table_name for a32
select owner,table_name,STATTYPE_LOCKED from dba_tab_statistics where table_name='TABLE_TEST' and owner='ESQUEMA';

OWNER                    TABLE_NAME                       STATT
------------------------ -------------------------------- -----
ESQUEMA                   TABLE_TEST           ALL
 

Los posible valores para el campo STATTYPE_LOCKED son :NULL, DATA, CACHE y ALL. Si esta en NULL significa que no esta bloqueada.

Para desblquear las estadísticas
exec dbms_stats.unlock_table_stats('ESQUEMA', 'TABLE_TEST');
PL/SQL procedure successfully completed.

Para ejecutar este procedimiento debe ser owner de la tabla o tener el privilegio ANALYZE ANY.

Fuente:
https://docs.oracle.com/database/121/ARPLS/d_stats.htm

Comments