导出数据:
编写创建路径文件:create_dir.sql
create or replace directory dmpdir as 'E:\app\tmp';
grant read, write on directory dmpdir to test;
exit
编写执行导出Bat文件:export.bat
sqlplus system/root123@MYTEST @create_dir.sql
expdp system/root123@MYTEST schemas=test directory=dmpdir dumpfile=MYTEST.DMP
MYTEST要备份的数据库
导入数据
编写创建User文件:create_user.sql
drop user test2 cascade;
create user test2 identified by password;
grant connect, resource to test2;
create or replace directory dmpdir as 'E:\app\tmp';
grant read, write on directory dmpdir to test2;
exit
编写执行导入Bat文件:restore.bat
sqlplus system/root123@localhost:1521/MYTEST @create_user.sql
impdp system/root123@localhost:1521/MYTEST schemas=test directory=dmpdir dumpfile=MYTEST.DMP table_exists_action=replace remap_schema=test:test2