时间:2021-07-01 10:21:17 帮助过:6人阅读
Step 1:赋予权限
登录到本地Oracle输入下面命令:
SQL> grant unlimited tablespace to SCOTT; SQL> grant read,write on directory data_pump_dir to SCOTT; SQL> grant execute on dbms_datapump to SCOTT; SQL> @/usr/oracle/dumpscott.sql
PL/SQL procedure successfully completed.
dumpscott.sql 内容:
DECLARE hdnl NUMBER; BEGIN hdnl := DBMS_DATAPUMP.open( operation => ‘EXPORT‘, job_mode => ‘SCHEMA‘, job_name=>null); DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => ‘scott.dmp‘, directory => ‘DATA_PUMP_DIR‘, filetype => dbms_datapump.ku$_file_type_dump_file); DBMS_DATAPUMP.add_file( handle => hdnl, filename => ‘exp.log‘, directory => ‘DATA_PUMP_DIR‘, filetype => dbms_datapump.ku$_file_type_log_file); DBMS_DATAPUMP.METADATA_FILTER(hdnl,‘SCHEMA_EXPR‘,‘IN (‘‘SCOTT‘‘)‘); DBMS_DATAPUMP.start_job(hdnl); END; /
Step 4: 使用 DBMS_FILE_TRANSFER 传输 dump file 到 Amazon RDS DB
BEGIN
DBMS_FILE_TRANSFER.PUT_FILE(
source_directory_object => ‘DATA_PUMP_DIR‘,
source_file_name => ‘scott.dmp‘,
destination_directory_object => ‘DATA_PUMP_DIR‘,
destination_file_name => ‘scott_copied.dmp‘,
destination_database => ‘to_rds‘
);
END;
/
在sqlplus则行该SQL文件:
SQL> @/usr/oracle/putscott.sql
PL/SQL procedure successfully completed.
Step 4:利用Data pump 把数据import到RDS
impdp <username>@<TNS_ENTRY> DUMPFILE=user1copied.dmpDIRECTORY=DATA_PUMP_DIR full=y
输入如下内容:
impdp user@RDS_DB DUMPFILE=scott_copied.dmp DIRECTORY=DATA_PUMP_DIR full=y
提示输入密码后将自动完成上传导入过程。然后连接到RDS可以查询到SCOTT的emp表等草操作。此处会有两个error不过可以忽略
本文出自 “技术博客” 博客,请务必保留此出处http://raytech.blog.51cto.com/7602157/1684108
本地Oracle数据上传到AWS的RDS
标签:oracle 数据迁移 aws rds