導出/導入步驟:shell
expdp system/pwd directory=s_dirname dumpfile=mes1_20150810.dmp logfile=mes1_20150810.log schemas=mes1 CONTENT=METADATA_ONLY數據庫
1.在源資料庫s中查看mes1與mes4中全部表和索引存放的表空間名稱:服務器
SQL@S> SELECT DISTINCT TABLESPACE_NAME FROM DBA_TABLES WHERE OWNER IN('MES1','MES4'); SQL@S> SELECT DISTINCT TABLESPACE_NAME FROM DBA_INDEXES WHERE OWNER IN ('MES1','MES4');
2.根據查詢結果,在目標數據庫t中創建相同名稱的表空間,數據文件位置根據t服務器實際磁盤分區決定.能夠與s數據文件位置不一樣.oracle
SQL@T> CREATE TABLESPACE CMES DATAFILE 'XXXX.DBF' SIZE 300M AUTOEXTEND ON 30M;
……spa
3.在t中新建帳號mes1/mes4/ztm01t1_ap,角色cit_group/mes_select.默認表空間設置爲mes_user
日誌
SQL@T> CREATE USER MES1 IDENTIFIED BY pwd DEFAULT TABLESPACE mes_user; SQL@T> CREATE USER MES4 IDENTIFIED BY pwd DEFAULT TABLESPACE mes_user; SQL@T> CREATE USER ztm01t1_ap IDENTIFIED BY pwd DEFAULT TABLESPACE mes_user; SQL@T> GRANT CONNECT TO ztm01t1_ap; SQL@T> CREATE ROLE cit_group NOT IDENTIFIED; SQL@T> CREATE ROLE mes_select NOT IDENTIFIED; SQL@T> GRANT CONNECT TO cit_group; SQL@T> GRANT CONNECT TO mes_select;
4.將s中mes1的數據使用數據泵導出.code
4.1 在s中查找可讀寫的目錄對象對象
SQL@S> SELECT DIRECTORY_NAME,DIRECTORY_PATH FROM DBA_DIRECTORIES;
4.2 導出s中MES1用戶下的全部數據索引
oracle@S> expdp system/pwd directory=s_dirname dumpfile=mes1_20150810.dmp logfile=mes1_20150810.log schemas=mes1
4.3 在t中查找可讀寫的目錄對象,拷貝mes1_20150810.dmp到對應目錄下ci
SQL@T> SELECT DIRECTORY_NAME,DIRECTORY_PATH FROM DBA_DIRECTORIES;
4.4 使用數據泵,將mes1數據導入t,注意查看日誌是否有報錯信息.
oracle@T> impdp system/pwd directory=t_dirname dumpfile=mes1_20150810.dmp logfile=mes1_20150810.log schemas=mes1
5. 一樣方法將mes4/ztm01_ap下的數據導入t
注意:ztm02_ap用戶下的數據導入t時,添加參數remap_schema,以下:
oracle@T> impdp system/pwd directory=t_dirname dumpfile=mes1_20150810.dmp logfile=mes1_20150810.log schemas=ztm01_ap remap_schema=ztm01_ap:ztm01t1_ap
6.比較s與t各用戶下對象數目是否相同,若是不一樣考慮從新導入數據
SQL@S> SELECT OWNER,OBJECT_TYPE,COUNT(OBJECT_TYPE) FROM DBA_OBJECTS WHERE OWNER IN ('MES1','MES4','ZTM01_AP') GROUP BY OWNER,OBJECT_TYPE ORDER BY OWNER;
7.根據s,在t的對應帳號授予對象權限(以MES1用戶爲例)
SQL@S> SELECT GRANTEE,OWNER,TABLE_NAME,PRIVILEGE FROM DBA_TAB_PRIVS WHERE OWNER='MES1'; SQL@T> GRANT INSERT ON MES1.XXX TO XXXX;
導出c開頭的表
expdp system/Foxconn88 directory=expdp_dir dumpfile=test02.dmp schemas=test INCLUDE=TABLE:"LIKE'C%'"
導出除了c開頭的表
expdp system/Foxconn88 directory=expdp_dir dumpfile=test05.dmp schemas=test INCLUDE=TABLE:\"NOT LIKE \'C%\'\"
導出某個表
expdp system/Foxconn88 directory=expdp_dir dumpfile=test08.dmp schemas=test INCLUDE=TABLE:\"IN\(\'C01\',\'C02\',\'C03\'\)\"
導出除了C01,C02的表
expdp system/Foxconn88 directory=expdp_dir dumpfile=test10.dmp schemas=test EXCLUDE=TABLE:\"IN\(\'C01\',\'C02\'\)\"
配額(quota):容許被使用的空間
SQL>conn sys/password as sysdba; SQL>alter user myuser quota 10M[unlimited] on users;
這個問題若是在授予權限時授予reource角色就不會出現。