第一種情況:
目標(biāo)數(shù)據(jù)庫(kù)中存在與導(dǎo)出用戶的缺省表空間同名的表空間,此時(shí),一定要將導(dǎo)入用戶的 unlimited tablespace 權(quán)限 revoke 掉,否則,數(shù)據(jù)將全部被導(dǎo)入到那個(gè)同名的表空間中,而不是導(dǎo)入用戶的缺省表空間中。
1、 從源數(shù)據(jù)庫(kù)中導(dǎo)出數(shù)據(jù)
(1) 授予導(dǎo)出用戶DBA權(quán)限
SQL> connect system@njgajhpt
Connected to Oracle9i Enterprise Edition Release 9.2.0.4.0
Connected as system
SQL> grant dba to sh;
Grant succeeded
SH的缺省表空間是EXAMPLE
SQL> select username,default_tablespace from dba_users
2 where username = 'SH';
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
SH EXAMPLE
(2)、導(dǎo)出數(shù)據(jù)
C:Documents and Settingscuiqing>exp sh/sh@njgajhpt file='d:tempsh.dmp' tables=customers direct=y
Export: Release 9.2.0.1.0 - Production on 星期四 11月 16 16:36:31 2006
即將導(dǎo)出指定的表通過(guò)直接路徑 ...
. . 正在導(dǎo)出表 CUSTOMERS 50000 行被導(dǎo)出
在沒(méi)有警告的情況下成功終止導(dǎo)出。
2、 導(dǎo)入目標(biāo)數(shù)據(jù)庫(kù)
(1) 創(chuàng)建表空間
SQL> create tablespace ts_qcui
2 datafile 'D:ORACLEORADATAJWPTZJKts_qcui.ora'
3 size 20M autoextend on next 8M maxsize 1024M;
Tablespace created
(2) 創(chuàng)建用戶
SQL> create user qcui identified by qcui
2 default tablespace ts_qcui;
User created
SQL> grant connect,resource to qcui;
Grant succeeded
(3) 導(dǎo)入數(shù)據(jù)
C:Documents and Settingscuiqing>imp qcui/qcui@jwptzjk fromuser=sh touser=qcui file='d:tempsh.dmp' constraints=n
Import: Release 9.2.0.1.0 - Production on 星期四 11月 16 16:43:00 2006
經(jīng)由直接路徑導(dǎo)出由EXPORT:V09.02.00創(chuàng)建的導(dǎo)出文件
IMP-00013: 只有 DBA 才能導(dǎo)入由其它 DBA 導(dǎo)出的文件
IMP-00000: 未成功終止導(dǎo)入
(4) 授予導(dǎo)入用戶DBA權(quán)限
SQL> grant dba to qcui;
Grant succeeded
(5) 授權(quán)后重新導(dǎo)入
C:Documents and Settingscuiqing>imp qcui/qcui@jwptzjk fromuser=sh touser=qcui file='d:tempsh.dmp' constraints=n
經(jīng)由直接路徑導(dǎo)出由EXPORT:V09.02.00創(chuàng)建的導(dǎo)出文件
警告: 此對(duì)象由 SH 導(dǎo)出, 而不是當(dāng)前用戶
. . 正在導(dǎo)入表 "CUSTOMERS" 50000行被導(dǎo)入
成功終止導(dǎo)入,但出現(xiàn)警告。
(6) 檢查數(shù)據(jù)存放的表空間。數(shù)據(jù)沒(méi)有按預(yù)期存放在QCUI的缺省表空間TS_QCUI中
SQL> select table_name,tablespace_name from dba_tables
2 where owner = 'QCUI';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
CUSTOMERS EXAMPLE
(7) 回收QCUI的unlimited tablespace權(quán)限
SQL> revoke unlimited tablespace from qcui;
Revoke succeeded
SQL> alter user qcui quota unlimited on ts_qcui;
User altered
(8) 回收權(quán)限后重新導(dǎo)入
SQL> drop table qcui.customers;
Table dropped
C:Documents and Settingscuiqing>imp qcui/qcui@jwptzjk fromuser=sh touser=qcui file='d:tempsh.dmp' constraints=n
經(jīng)由直接路徑導(dǎo)出由EXPORT:V09.02.00創(chuàng)建的導(dǎo)出文件
警告: 此對(duì)象由 SH 導(dǎo)出, 而不是當(dāng)前用戶
. . 正在導(dǎo)入表 "CUSTOMERS" 50000行被導(dǎo)入
成功終止導(dǎo)入,但出現(xiàn)警告。
(9) 檢查數(shù)據(jù)存放的表空間。數(shù)據(jù)存放在QCUI的缺省表空間TS_QCUI中
SQL> select table_name,tablespace_name from dba_tables
2 where owner = 'QCUI';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
CUSTOMERS TS_QCUI