ORA-00959: el tablespace ‘_$deleted$82$0’ no existe durante un impdp

Nos hemos mudado a bloger!
El contenido actualizado de esta entrada lo tienes en:

    http://dba.pamplona.name/2013/08/ora-00959-el-tablespace-no-existe.html

    Hoy vamos a ver como solucionar los problemas ORA-00959 cuando van asociados a un tablespace borrado.
    Este error es bastante común y es un bug identificado de oracle que es facil que te encuentres cuando se usan tablas particionadas, y se elimina o se mueve el tablespace original de la tabla. Es muy habitual el rehacer los objetos indicando los tablespaces por defecto de las particiones, pero no cambiando el de la tabla original
    Esto hace que, cuando vayas a importar la tabla, el tablespace original de la tabla no exsista, recibiendo el error del enunciado.

    ¿Como lo solucionamos?

    Hay 2 maneras:

    1- Solucion en origen
    Esta es la solución correcta, y lo que hacemos es buscar que tablas tienen la sintaxsis de creacion en un tablespace inexistente y modificarlas.

    select distinct 'ALTER INDEX '||index_owner||'.'||index_name||' MODIFY DEFAULT ATTRIBUTES TABLESPACE '||tablespace_name||';' cmd from dba_ind_partitions where tablespace_name not in ('SYSTEM','SYSAUX') order by 1;
    
     select distinct 'ALTER INDEX '||index_owner||'.'||index_name||' MODIFY DEFAULT ATTRIBUTES FOR PARTITION '||partition_name||' TABLESPACE '||tablespace_name||';' cmd from dba_ind_subpartitions where tablespace_name not in ('SYSTEM','SYSAUX') order by 1;
    
     select distinct 'ALTER TABLE '||table_owner||'.'||table_name||' MODIFY DEFAULT ATTRIBUTES TABLESPACE '||tablespace_name||';' cmd from dba_tab_partitions where tablespace_name not in ('SYSTEM','SYSAUX') order by 1;
    
     select distinct 'ALTER TABLE '||table_owner||'.'||table_name||' MODIFY DEFAULT ATTRIBUTES FOR PARTITION '||partition_name||' TABLESPACE '||tablespace_name||';' cmd from dba_tab_subpartitions where tablespace_name not in ('SYSTEM','SYSAUX') order by 1;
    
     select 'alter user '||username||' default tablespace '||default_tablespace||' temporary tablespace '||temporary_tablespace||';' cmd from dba_users order by default_tablespace;
    

    Y ejecutamos la salida de estas consultas

    2- Solucion en destino

    Creamos a mano las tablas que dan el error e importamos con la opcion «truncate»

    NOTA:
    Indpendientemente de estas chapucillas, lo mejor será contactar con soporte oracle para identificar el bug que nos afecta y parchear la base de datos