[Oracle] expdp 수행 도중 ORA-02032: clustered tables cannot be used before the cluster index is built (ORA-31693, 2354, 2373, 2032)

728x90

expdp를 받는데, log에 특정 테이블들에 대해 에러가 났더라고요.

ORA-31693: Table data object "스키마"."테이블명" failed to load/unload and is being skipped due to error:
ORA-02354: error in exporting/importing data
ORA-02373: Error parsing insert statement for table "스키마"."테이블명".
ORA-02032: clustered tables cannot be used before the cluster index is built

 

나머지 테이블들은 expdp가 정상적으로 잘 수행되었습니다.

 

원인 분석

ORA-02032clustered tables cannot be used before the cluster index is built

 

클러스터 인덱스 없이는 클러스터 테이블을 사용할 수 없다는 내용입니다.

 

log에 에러와 함께 출력된 테이블이 먼저 클러스터 테이블인지 확인했습니다.

  • 연결된 클러스터가 있는지 cluster_name 컬럼으로 확인
set lines 300 pages 1000
col owner for a15
col cluster_name for a30
col tablespace_name for a30
col TABLE_NAME for a30

select owner, table_name, tablespace_name, cluster_name 
from dba_tables 
where owner='스키마명' 
and table_name='테이블명';

OWNER           TABLE_NAME                     TABLESPACE_NAME                CLUSTER_NAME
--------------- ------------------------------ ------------------------------ ------------------------------
TEST            DEPARTMENTS                    USERS                          DEPT_EMP_CLUSTER

 

해당 테이블의 데이터 조회는 안되더라고요.

SQL> select * from test.departments;
select * from test.departments
                   *
ERROR at line 1:
ORA-02032: clustered tables cannot be used before the cluster index is built

 

DEPT_EMP_CLUSTER 클러스터의 존재 여부 및 정보를 파악했습니다.

set lines 300 pages 1000
col owner for a15
col cluster_name for a30
col tablespace_name for a30

select owner, cluster_name, tablespace_name, cluster_type
from dba_clusters
where owner='스키마명' 
and cluster_name='클러스터명';


OWNER           CLUSTER_NAME                   TABLESPACE_NAME                CLUST
--------------- ------------------------------ ------------------------------ -----
TEST            DEPT_EMP_CLUSTER               USERS                          INDEX

 

클러스터에 속한 클러스터 인덱스를 조회해봤습니다.

table_name클러스터명을 입력하시면 됩니다.

col index_name for a30
col table_name for a30
col tablespace_name for a30

select owner, index_name, index_type, table_name, table_type, tablespace_name
from dba_indexes
where index_type='CLUSTER'
and table_name='클러스터명';

no rows selected

 

클러스터 인덱스가 없었던 게 원인이었습니다.

 

참고)

정상 조회된다면 아래와 같습니다.

OWNER           INDEX_NAME                     INDEX_TYPE                  TABLE_NAME                     TABLE_TYPE  TABLESPACE_NAME
--------------- ------------------------------ --------------------------- ------------------------------ ----------- ------------------------------
TEST            IDX_DEPT_EMP_CLUSTER           CLUSTER                     DEPT_EMP_CLUSTER               CLUSTER     USERS

 

재현 테스트

실제로 클러스터를 생성해 보고,

클러스터 인덱스 없이 클러스터 테이블을 생성해보았습니다.

클러스터 테이블 생성은 문제 없이 잘 되더라고요.

SQL> create cluster dept_emp_cluster ( dept_id number ) size 512;

Cluster created.

SQL> CREATE TABLE departments (
  dept_id NUMBER PRIMARY KEY,
  dept_name VARCHAR2(100)
) CLUSTER dept_emp_cluster (dept_id);

Table created.

 

문제는 클러스터 인덱스가 없기 때문에 DB 자체에서도 클러스터 테이블을 사용할 수 없는 걸 확인할 수 있었습니다.


SQL> select * from test.departments;
select * from test.departments
                   *
ERROR at line 1:
ORA-02032: clustered tables cannot be used before the cluster index is built




SQL> insert into test.departments (dept_id, dept_name) values (10, 'HR');
insert into test.departments (dept_id, dept_name) values (10, 'HR')
                 *
ERROR at line 1:
ORA-02032: clustered tables cannot be used before the cluster index is built

 

클러스터 인덱스를 생성하고 다시 보면 정상 수행되는 걸 확인할 수 있었습니다.

CREATE INDEX idx_dept_emp_cluster
ON CLUSTER dept_emp_cluster
TABLESPACE users;

Index created.

 

SQL> insert into test.departments (dept_id, dept_name) values (10, 'HR');

1 row created.


SQL> select * from test.departments;

   DEPT_ID DEPT_NAME
---------- ----------------------------------------------------------------------------------------------------
        10 HR

 

728x90