您好,登录后才能下订单哦!
如何安装Oracle跟创建Oracle的AWS RDS在此就不再详述。只是简单的在本地Oracle创建一些简单的数据,后尝试导入RDS.
·
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不过可以忽略
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。