martes, 25 de febrero de 2014

ORA-38029 y ORA-20005 Tras Hacer un Import con ROWS=N

Este ejemplo es una traducción española basada en información que leí aquí. Lo probé en Oracle 11.2.0.2.7. Creé una tabla y confirmé que podía calcular sus estadísticas con ANALYZE y DBMS_STATS:

SQL> create table tab1(col1 number)
  2  /
 
Tabla creada.
 
SQL> analyze table tab1 compute statistics
  2  /
 
Tabla analizada.
 
SQL> exec dbms_stats.gather_table_stats(-
> ownname=>'OPS$ORACLE',tabname=>'TAB1');
 
Procedimiento PL/SQL terminado correctamente.
 
SQL>

Luego hice un export de la tabla así:

exp / tables=tab1 \
      file=exp.dmp \
      log=exp.log \
      statistics=none
 
ORCL /export/home/oracle/andrew/ORA-38029 > cat exp.log
 
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8MSWIN1252 character set (possible charset conversion)
 
About to export specified tables via Conventional Path ...
. . exporting table                           TAB1          0 rows exported
Export terminated successfully without warnings.
ORCL /export/home/oracle/andrew/ORA-38029 >

Entonces hice un import con ROWS=N: 

imp / tables=tab1 \
      file=exp.dmp \
      log=imp.log \
      ignore=y \
      rows=n
 
ORCL /export/home/oracle/andrew/ORA-38029 > cat imp.log
 
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
Export file created by EXPORT:V11.02.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8MSWIN1252 character set (possible charset conversion)
. importing OPS$ORACLE's objects into OPS$ORACLE
. importing OPS$ORACLE's objects into OPS$ORACLE
Import terminated successfully without warnings.
ORCL /export/home/oracle/andrew/ORA-38029 >
 
Después de hacer el import, las estadísticas de la tabla estaban cerradas con llave. Tenía que emplear DBMS_STATS.UNLOCK_TABLE_STATS en la tabla antes de calcular sus estadísticas:

SQL> analyze table tab1 compute statistics
  2  /
analyze table tab1 compute statistics
*
ERROR en linea 1:
ORA-38029: las estadisticas de objetos estan
bloqueadas
 
SQL> exec dbms_stats.gather_table_stats(-
> ownname=>'OPS$ORACLE',tabname=>'TAB1');
BEGIN dbms_stats.gather_table_stats( ownname=>'OPS$ORACLE',tabname=>'TAB1'); END;
 
*
ERROR en linea 1:
ORA-20005: object statistics are locked (stattype =
ALL)
ORA-06512: en "SYS.DBMS_STATS", linea 23154
ORA-06512: en "SYS.DBMS_STATS", linea 23205
ORA-06512: en linea 1
 
SQL> exec dbms_stats.unlock_table_stats(-
> ownname=>'OPS$ORACLE',tabname=>'TAB1');
 
Procedimiento PL/SQL terminado correctamente.
 
SQL> analyze table tab1 compute statistics
  2  /
 
Tabla analizada.
 
SQL> exec dbms_stats.gather_table_stats(-
> ownname=>'OPS$ORACLE',tabname=>'TAB1');
 
Procedimiento PL/SQL terminado correctamente.
 
SQL>

Repetí la prueba (desde el principio) PERO hice el import sin ROWS=N:

imp / tables=tab1 \
      file=exp.dmp \
      log=imp.log \
      ignore=y
 
ORCL /export/home/oracle/andrew/ORA-38029 > cat imp.log
 
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
Export file created by EXPORT:V11.02.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8MSWIN1252 character set (possible charset conversion)
. importing OPS$ORACLE's objects into OPS$ORACLE
. importing OPS$ORACLE's objects into OPS$ORACLE
. . importing table                         "TAB1"          0 rows imported
Import terminated successfully without warnings.
ORCL /export/home/oracle/andrew/ORA-38029 >
 
Esta vez, las estadísticas de la tabla no estaban cerradas con llave. Así estaba permitido calcularlas sin emplear DBMS_STATS.UNLOCK_TABLE_STATS:
 
SQL> analyze table tab1 compute statistics
  2  /
 
Tabla analizada.
 
SQL> exec dbms_stats.gather_table_stats(-
> ownname=>'OPS$ORACLE',tabname=>'TAB1');
 
Procedimiento PL/SQL terminado correctamente.
 
SQL>

Javier Morales, el autor del libro siguiente, me ayuda con unos de mis ejemplos:

No hay comentarios:

Publicar un comentario