这篇文章主要讲解了“ORACLE和MYSQL怎么互相导入数据”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“ORACLE和MYSQL怎么互相导入数据”吧!
只是一个列子和方法具体的选项按需求添加
1、ORACLE卸载数据
DECLARE
row_result varchar2(4000);
selectsql varchar2(4000);
qrycursor SYS_REFCURSOR;
txt_handle UTL_FILE.file_type;
BEGIN
--selectsql := 'select id || '','' || name || '','' || dti from testdump where name = ''gaopeng'' and dti > to_date(''2015-03-17 00:00:00'', ''yyyy-mm-dd hh34:mi:ss'')';
selectsql := 'select nvl(to_char(id),''\N'')||'',''||nvl(name,''\N'')||'',''||nvl(to_char(dt,''yyyy-mm-dd''),''\N'') from txt';
txt_handle := UTL_FILE.FOPEN('DATA_PUMP_DIR', 'testnull1.txt', 'w', 32767);
open qrycursor for selectsql;
loop
fetch qrycursor
into row_result;
exit when qrycursor%notfound;
UTL_FILE.PUT_LINE(txt_handle, row_result);
end loop;
--关闭游标
close qrycursor;
UTL_FILE.FCLOSE(txt_handle);
end;
2、导入到MYSQL
MYSQL LOAD DATA INFILE
1,gaopeng,2010-10-10
2,gaopeng2,2011-11-12
3,gaopeng3,2011-12-13
load data infile '/tmp/testnull1.txt' into table txt fields terminated by ',' LINES TERMINATED BY '\n';
3、MYSQL卸载数据
SELECT id,name,dt into outfile "/tmp/test2.txt"
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FROM txt ;
4、导入到ORACLE
1,gaopeng,2010-10-10
2,gaopeng2,2011-11-12
3,gaopeng3,2011-12-13
append 可以换成 replace
按需求修改
load data
infile '/home/oradba/loadr/in.txt'
badfile '/home/oradba/loadr/bad.txt'
DISCARDFILE '/home/oradba/loadr/dc.txt'
append
into table txt
fields terminated by ','
(id,
name,
dt char "to_date(:dt,'YYYY-MM-DD')"
)
sqlldr userid=ppzhu/gelc123 control=/home/oradba/loadr/ld.ctl log=/home/oradba/loadr/log.log
感谢各位的阅读,以上就是“ORACLE和MYSQL怎么互相导入数据”的内容了,经过本文的学习后,相信大家对ORACLE和MYSQL怎么互相导入数据这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!