2010. 3. 15. 12:27
Export
$ exp userid = 유저명과 패스워드를 쓴다. 예제) userid = scott/tiger
file = Export 받는 Dump File을 지정한다. 예제) file = /data/backup/0315.dmp
log = Export 받을 때 Log File을 지정할 수 있다. log = /data/backup/0315.exp
*rows = 데이타를 받을 것인지 아닌지를 지정한다. Default 값은 y 이다. 예제) rows = y
*constraints = Table에 셋팅된 제약 조건을 받을 것인지 지정한다. Default 값은 y 이다. 예제) constraints = y
*indexes = Index를 받을 것인지를 지정한다. Default 값은 y 이다. 예제) indexes = y
tables = 유저의 특정 Table을 받고자 할 때 사용된다. 예제) tables = 사원,부서
Default는 userid가 작성한 모든 Table을 받는다.
compress = Table을 위해 extebt된 값이 Storage 값의 INITIAL 값에 셋팅된다.
Default 값은 compress = y 이지만, compress = n 이 안전하다.
*full = userid가 system/manager나 dba 권한이 있는 유저일 경우 Database 전체를 exp 받을 수 있다.
exp 예제)
$ exp userid=system/manager file=/data/backup/0315.dmp log=/data/backup/0315.exp full=y
< 연습 예제 >
1. scott 사용자의 모든 데이터를 전부 백업 받는 경우
$ exp userid=scott/tiger file=/data/backup/0315.dmp log=/data/backup/0315.exp
2. scott 유저의 constraint 와index 를 빼고 Synonym,View,Table 의 데이타만 받는 경우
$ exp userid=scott/tiger file=/data/backup/0315.dmp log=/data/backup/0315.exp rows=y constraints=n indexes=n
3. Data만 빼고 Index와 제약 조건만 받고자 한다면
$ exp userid=scott/tiger file=/data/backup/0315.dmp log=/data/backup/0315.exp rows=n constraints=y indexes=y
Export하면, Dunp File은 Export하는 User에 필요한 모든 사항들이 SQL 문장으로 작성된다.
즉, CREATE TABLESPACE, CREATE TABEL ...., CREATE VIEW .., CREATE INDEX .. INSERT INTO .... 문장으로 구성된다.
주의할 사항은 CREATE TABLE (.. ..) tablespace tbs_name; 과 같이 Table이나 Index의 Tablespace나 Storage값이 정의되므로 Table이 저장될 Tablespace의 위치를 바꾸고자 할 때는 단순 EXPort/IMPort 방법만으로는 안된다.
그렇다고 이 화일을 직접 편집하면 Dump File이 손상되므로 직접 편집하면 안된다.
Import
$ imp userid=Import할 유저명. Export한 유저명과 동일해야 한다.
file = Export한 Dumf file명
log = Import Log file
indexfile = Data를 Import하지 않고 CREATE INDEX 문장의 SQL로 File이 만들어진다.
rows = Data를 Import할지의 여부를 선택한다. (y : n )
indexes = Index를 Import할지의 여부를 선택한다. ( y : n )
fromuser = 다른 User에게 Export File을 Import하고자 할 때 Export한 User를 지정한다.
touser = Import할 User를 지정한다.
※ fromuser , touser 옵션은 system/manager User에서만 사용할 수 있다.
igore = Import 도중 에러가 발생해도 무시하고 계속 진행한다.
< 연습 예제 >
1. 전체 Data 입력
$ imp userid=SYSTEM/password file=dba.dmp full=y
2. scott schema의 emp,dept만 입력
$ imp userid=SYSTEM/password file=dba.dmp fromuser=scott tables=(dept,emp)
3. jinsu schema의 Table을 scott schema로 변경해서 입력
$ imp userid=SYSTEM/password fromuser=jinsu touser=scott FILE=jinsu.dmp tables=(emp,dept)
'Oracle 10g > 10g - Admin I' 카테고리의 다른 글
Restore & Recovery (0) | 2010.03.08 |
---|---|
Backup (0) | 2010.03.08 |
sysdba 권한 로그인시 패스워드 지정 (0) | 2010.03.05 |
프로파일 & 유저 관리 & 권한 관리 (0) | 2010.03.05 |
Constraints (제약 조건) (0) | 2010.03.05 |