[Oracle] Dump를 이용한 데이터 이행5 (DATABASE 레벨)

·2025년 9월 11일
0

오라클 관리

목록 보기
131/163

💡 database level로 export / import의 옵션 3가지

  1. complete
    : database 전체를 export
  2. incremental
    : database 전체를 export한 이후에 변경된 부분만 export
  3. cumulative
    : 변경된 부분만 누적해서 export


[실습1] database level 로 export 하는데 옵션을 complete 로 export 하시오

[oracle@ora19c ~]$ export ORACLE_SID=ORA19
[oracle@ora19c ~]$
[oracle@ora19c ~]$ exp full=y file=complete01.dmp inctype=complete

🔸 [문제] ORA19 의 hrts 테이블스페이스를 ora19dw 로 테이블스페이스 레벨로 이행하시오

1. ORA19 쪽에서 테이블스페이스를 생성

create tablespace  hrts
 datafile '/u01/app/oracle/oradata/ORA19/hrts01.dbf' size 500m;

2. hr로 접속해서 hrts 테이블스페이스에 emp 테이블과 dept 테이블을 생성

alter session set nls_Date_format='RR/MM/DD';
drop table emp;
drop table dept;


CREATE TABLE DEPT
       (DEPTNO number(10),
        DNAME VARCHAR2(14),
        LOC VARCHAR2(13) )
        tablespace hrts;


INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK');
INSERT INTO DEPT VALUES (20, 'RESEARCH',   'DALLAS');
INSERT INTO DEPT VALUES (30, 'SALES',      'CHICAGO');
INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON');

CREATE TABLE EMP (
 EMPNO               NUMBER(4) NOT NULL,
 ENAME               VARCHAR2(10),
 JOB                 VARCHAR2(9),
 MGR                 NUMBER(4) ,
 HIREDATE            DATE,
 SAL                 NUMBER(7,2),
 COMM                NUMBER(7,2),
 DEPTNO              NUMBER(2) )
   tablespace hrts;


INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,'81-11-17',5000,NULL,10);
INSERT INTO EMP VALUES (7698,'BLAKE','MANAGER',7839,'81-05-01',2850,NULL,30);
INSERT INTO EMP VALUES (7782,'CLARK','MANAGER',7839,'81-05-09',2450,NULL,10);
INSERT INTO EMP VALUES (7566,'JONES','MANAGER',7839,'81-04-01',2975,NULL,20);
INSERT INTO EMP VALUES (7654,'MARTIN','SALESMAN',7698,'81-09-10',1250,1400,30);
INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,'81-02-11',1600,300,30);
INSERT INTO EMP VALUES (7844,'TURNER','SALESMAN',7698,'81-08-21',1500,0,30);
INSERT INTO EMP VALUES (7900,'JAMES','CLERK',7698,'81-12-11',950,NULL,30);
INSERT INTO EMP VALUES (7521,'WARD','SALESMAN',7698,'81-02-23',1250,500,30);
INSERT INTO EMP VALUES (7902,'FORD','ANALYST',7566,'81-12-11',3000,NULL,20);
INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,'80-12-09',800,NULL,20);
INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,'82-12-22',3000,NULL,20);
INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,'83-01-15',1100,NULL,20);
INSERT INTO EMP VALUES (7934,'MILLER','CLERK',7782,'82-01-11',1300,NULL,10);


commit;

3. sys 로 접속해서 hrts 테이블스페이스를 read only 로 변경

select  t.name, d.enabled
 from  v$tablespace   t, v$datafile   d
 where  t.ts# = d.ts#;

alter tablespace hrts read only;

select  t.name, d.enabled
 from  v$tablespace   t, v$datafile   d
 where  t.ts# = d.ts#;

4. hrts 테이블스페이스를 tablespace 레벨로 export 하기

[oracle@ora19c ~]$ ora19
ORA19
[oracle@ora19c ~]$ exp transport_tablespace=y tablespaces=hrts file=hrts.dmp

Export: Release 19.0.0.0.0 - Production on911 16:34:33 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


사용자명: sys as sysdba
비밀번호:

5. import 할 때 hrts.dmp 덤프 파일과 hrts01.dbf 파일 2개가 필요함

[oracle@ora19c ~]$ cp /u01/app/oracle/oradata/ORA19/hrts01.dbf /home/oracle/hrts01.dbf

[oracle@ora19c ~]$ ls -l hrts01.dbf
-rw-r-----. 1 oracle oinstall 524296192  9월 11 16:36 hrts01.dbf

[oracle@ora19c ~]$ ls -l hrts.dmp
-rw-r--r--. 1 oracle oinstall 57344  9월 11 16:34 hrts.dmp


[oracle@ora19c ~]$ sysdw

SQL*Plus: Release 19.0.0.0.0 - Production on911 16:38:24 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


다음에 접속됨:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SYS @ ora19dw > drop user hr cascade;

사용자가 삭제되었습니다.

SYS @ ora19dw > create user hr identified by hr;

사용자가 생성되었습니다.

SYS @ ora19dw > grant dba to hr;

권한이 부여되었습니다.

SYS @ ora19dw > exit;
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0에서 분리되었습니다.

6. ora19dw 쪽에 import를 수행

[oracle@ora19c ~]$ echo $ORACLE_SID
ora19dw

[oracle@ora19c ~]$ imp transport_tablespace=y file=hrts.dmp datafiles='/home/oracle/hrts01.dbf'

Import: Release 19.0.0.0.0 - Production on911 16:40:08 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

사용자 이름: sys as sysdba
비밀번호:

다음에 접속됨: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
.
.
.
. SYS 객체를 SYS()로 임포트하는 중입니다
경고와 함께 임포트가 정상 종료되었습니다.


오라클 교육 테이블들을 모두 생성하시오


0개의 댓글