About migration - Overview 0 1 7,938

by 다솜여우 export import index constraints synonym db_link trigger [2009.06.15 23:04:07]


migration에 대해서 간단하게 정리했습니다.

자세한 내용은 오라클 메뉴얼을 참고하시거나, 고수분들의 코멘트를 감사히 받겠습니다.

 

I. export/import


1.  주의사항 작업

  1) os 와 오라클 버젼확인

  2) data용량 확인

  3) export 해서 추출할 dump파일 저장공간확인

  4) 어떤 방법으로 (full level, userlevel, tablelevel) 할것인지확인

  5) import할곳에 테이블스페이스 만들어주기

  6) oracle버젼이 다를 경우 user level, table level로 export : 퍼미션,퍼블릭을 가지고 갈 수 없으므로 기존데이터에 스크립트를 돌려서 나온 파일을 import시킨 파일에 스크립트를 돌려서 퍼미션 퍼블릭 넣어주기 

  7) 9i ⇒ 10g 등 구버젼에서 최신버전으로 migration : 특별하게 따로 데이터 변경작업을 해주지 않아도 됨
 (단, 10.2.1 -> 10.2.3 으로 옮길 경우 : 별도 작업 필요)

  8) 두 oracle간의 문자셋이 같아야 import export 가능(일반적으로)


2. 사전 작업

  1) 현재 사용하고 있는 테이블스페이스와 디폴드 템프 테이블 스페이스 조회 (기존 DB )
  
  SQL> select username, default_tablespace, temporary_tablespace from dba_users;
 
  2) 권한 조회하기
  SQL> select * from dba_role_privs;
 
  3) Export 작업 : 기존 오라클에서 하여야 할 일
    ⓐ 테이블별로 export 받기
 $ exp system/패스워드 owner=사용자명 file=###)dmp log=###)log buffer=8192000 compress=n feedback=100000 
 exp scott/oracle file=test)dmp log=test)log tables=emp, dept compress=n rows=y buffer=8192000 constraints=n indexes=n statistics=none

    ⓑ 사용자별로 export 받기
 $ exp system/manager owner=scott file=scott_test)dmp log=scott_test)log compress=n rows=y buffer=8192000 constraints=n indexes=n statistics=none

    ⓒ 인덱스만 export받기
 exp scott/oracle file=test_index)dmp log=test_index)log rows=n

    ⓓ 권한주기
 grant execute on sys)dbms~~ to scott ;


                                                                                              
3. Import 작업하기 : Import 하기전에 우선 pga_aggregate_target 을 넉넉히 주고 작업 할 것
                                                                                                
 $ imp system/패스워드 fromuser=사용자(export) touser=사용자(import) file=###.dmp log=###.log buffer=8192000 ignore=y commit=y feedback=100000

  1) 테이블별로 import 하기
    imp system/oracle FROMUSER=scott TOUSER=scott file=test.dmp log=imp_test.log feedback=10000 ignore=y commit=y buffer=8192000 statistics=safe rows=y

  2) 사용자별로 import 하기
    imp system/manager fromuser=scott touser=scott file=scott_test.dmp log=scott_imp.log rows=y ignore=y

  3) 인덱스만 import 하기
    select dbms_metadata.get_ddl('INDEX','DEPT_IDX','SCOTT') from dual;
       ==> 여기서 나온 결과를 index_scott.sql로 저장(9i NF)
    imp scott/oracle file=test_index.dmp log=imp_index.log indexfile=index_scott.sql


4. 제약조건 추가하기
ALTER TABLE "SCOTT"."DEPT" ADD ( CONSTRAINT "EMP_NO_FK" FOREIGN KEY ("EMP_NO","EMP_NAME") REFERENCES "SCOTT"."EMP" ("EMP_NO","EMP_NAME") VALIDATE );

 

5. 인덱스 생성
CREATE INDEX "SCOTT"."INDEX_EMP_EMP_NO" ON "SCOTT"."EMP" ("EMP_NO") TABLESPACE "TEST1";

 
6. SYNONYM
  0) 사용자별 SYNONYM 조회 방법
     select owner, synonym_name from dba_synonyms where table_owner='scott' order by owner, synonym_name;

  1) SYNONYM 생성 : 사용자로 접속해서 사용
     create synonym synonym_name for object_name;

  2) 사용자의 모든 테이블에 대한 SYNONYM 스크립트 작성 : 시너님 생성해서 나중에 넣어주기(확인할 것)
     select 'create synonym '||table_name|| ' for ' ||owner||'.'||table_name||';' from dba_tables where owner='IKIS_KRIVET';

  3) SYNONYM 삭제 구문
     drop synonym 시노님명;


 7. db_link
  1) 조회 : 기존 DB
    select * from all_db_links;
    select * from dba_db_links;
    select * from user_db_links;

  2) db_link 생성 방법
     create database link <링크로사용할이름> connect to <userid> identified by <passwd> using 'oraB(상대 서비스 네임)';


8. trigger
  1) SCOTT이 소유하고 있는 test라는 table에 걸려 있는 모든 trigger name과 trigger type, triggering event, status, trigger가 적용되는 column_name, 해당 object의 validity까지 한번에 조회


  2) query 문
   select t.owner, t.trigger_name,
   t.trigger_type,
   t.triggering_event,
   t.status,
   c.column_name,
   o.status as "VALIDITY"
   from dba_triggers t, dba_trigger_cols c, dba_objects o
   where t.owner = c.trigger_owner (+)
   and t.trigger_name = c.trigger_name (+)
   and t.owner = o.owner
   and t.trigger_name = o.object_name
   and o.object_type = 'TRIGGER'
   and t.table_owner = 'SCOTT'
   and t.table_name = 'TEST';

by 일등감자 [2009.06.16 10:54:02]
네. 좋은 정보 알려주셔서 고맙습니다.
한가지 물어볼게 있습니다. '1. 주의사항 작업' 에 보면은 아래와 같은 말이 있는데...

6) oracle버젼이 다를 경우 user level, table level로 export : 퍼미션,퍼블릭을 가지고 갈 수 없으므로 기존데이터에 스크립트를 돌려서 나온 파일을 import시킨 파일에 스크립트를 돌려서 퍼미션 퍼블릭 넣어주기

어떻게 하라는건지 이해가 않갑니다. 자세히좀 설명 부탁 드리겠습니다.

고맙습니다.
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입