1、输入cmd回车
2、用sqlplus登陆
sqlplus user/password@SERVICE_NAME
或sqlplus /nolog然后connect user/password@ip/实例
3、创建目录及授权
--先在windows下新建目录E:/dp_dmp
--创建目录
create directory dir_dp as 'E:/dp_dmp';
--授权目录
Grant read,write on directory dir_dp to system;
--检查授权
SELECT privilege, directory_name, DIRECTORY_PATH FROM user_tab_privs t, all_directories d WHERE t.table_name(+) = d.directory_name ORDER BY 2, 1;
4、导出模式
--按用户
expdp system/system@test dumpfile=dp_test.dmp schemas=test logfile=dp_test_exp.log directory=dir_dp job_name=test_job
--按表空间
expdp system/system@test dumpfile=dp_test.dmp tablespaces=test.dbf logfile=dp_test_exp.log directory=dir_dp job_name=test_job
--按表
expdp system/system@test dumpfile=dp_test.dmp tables=test.b$test logfile=dp_test_exp.log directory=dir_dp job_name=test_job
--按库
expdp system/system@test dumpfile=dp_test.dmp full=y logfile=dp_test_exp.log directory=dir_dp job_name=test_job
5、导入模式
--按用户
impdp system/system@test dumpfile=dp_test.dmp schemas=test logfile=dp_test_imp.log directory=dir_dp job_name=test_job
--按表空间
impdp system/system@test dumpfile=dp_test.dmp tablespaces=test.dbf logfile=dp_test_imp.log directory=dir_dp job_name=test_job
--按表
impdp system/system@test dumpfile=dp_test.dmp tables=test.b$test logfile=dp_test_imp.log directory=dir_dp job_name=test_job
6、更换表空间
--导入时更换表空间,原来表空间为A的导入到B的表空间
impdp system/system@test dumpfile=dp_test.dmp logfile=dp_test_imp.log directory=dir_dp remap_tablespace=A:B
7、不通过expdp的步骤生成dmp文件而直接导入的方法:
--从源数据库中向目标数据库导入表test、当然也可以是用户、表空间等
impdp system/system@test directory=dir_db network_link=testdb tables=test logfile=test_imp.log job_name=test_job
testdb是目的数据库与源数据的链接名,dir_dp是目的数据库上的目录