导出
-- 1、创建需要备份到的路径并赋权 sqlplus命令行执行
CREATE OR REPLACE DIRECTORY backup_path_name AS '/home/oracle/backup';
GRANT READ,WRITE ON DIRECTORY backup_path_name TO yourUserName;
-- 2、给用户赋导出的权限 sqlplus命令行执行
GRANT exp_full_database, imp_full_database TO yourUserName;
-- 3、导出所有用户对象 shell命令执行
expdp yourUserName/'yourPassword'@yourIp/yourOracleInstanceName DIRECTORY=backup_path_name dumpfile=yourFileName.dmp logfile=1yourFileName.log schemas=yourUserName;
导入,一个用户导入另一个用户的Schema
-- 1、创建需要备份到的路径并赋权 sqlplus命令行执行
CREATE OR REPLACE DIRECTORY import_path_name AS '/home/oracle/import';
GRANT READ,WRITE ON DIRECTORY import_path_name TO yourUserName1;
-- 2、给用户赋导出/入的权限 sqlplus命令行执行
GRANT exp_full_database, imp_full_database TO yourUserName1;
ALTER USER sd_hbtm QUOTA UNLIMITED ON yourUserName1;
-- 3、yourUserName1用户导入yourUserName2用户的数据
impdp yourUserName1/'yourUserName1Password'@yourIp/yourOracleInstanceName directory=import_path_name dumpfile=yourFileName.dmp remap_schema=yourUserName2:yourUserName1;