使用expdp和impdp迁移oracle数据库

4月 29, 2015 |

1、oracle导入.sql文件
在sqlplus中执行@xxx.sql --绝对路径
记得commit 或者set autocommit on

2、sqlplus 中文乱码
export NLS_LANG=AMERICAN_AMERICA.UTF8
export LANG=en_US.UTF-8

oracle 导入导出
1、创建DIRECTORY 对象
CREATE OR REPLACE DIRECTORY dmpdir AS '/u01/app/oracle/test_export';
-- dmpdir 目录对象名, as 后面的是文件夹路径

2、将目录对象的权限授予用户
GRANT READ,WRITE ON DIRECTORY dmpdir TO hr;

3、导出
expdp SYSTEM/password SCHEMAS=hr DIRECTORY=dmpdir DUMPFILE=schema.dmp LOGFILE=expschema.log

导入
在oracle 11g XE中不支持‘ref_constraint’
impdp SYSTEM/123456 SCHEMAS=nix_9527 DIRECTORY=dmpdir DUMPFILE=schema.dmp REMAP_SCHEMA=nix_9527:nix_cyl EXCLUDE=constraint, ref_constraint, index TABLE_EXISTS_ACTION=replace LOGFILE=impschema.log
ALTER USER hrdev IDENTIFIED BY hrdev;

1、先创建目录和创建表空间,表空间名和导出的相同
create tablespace test datafile '/u01/app/oracle/oradata/XE/test.dbf' size 200M;

2、导入
impdp SYSTEM/123456 SCHEMAS=nix_9527 DIRECTORY=dmpdir DUMPFILE=schema.dmp REMAP_SCHEMA=nix_9527:nix_123 EXCLUDE=constraint, ref_constraint, index TABLE_EXISTS_ACTION=replace LOGFILE=impschema.log

参考资料
http://docs.oracle.com/cd/E17781_01/server.112/e18804/impexp.htm#ADMQS272

Posted in: Uncategorized

Comments are closed.