這篇文章主要講解了“ORACLE和怎么互相導入數據”,文中的講解內容簡(jiǎn)單清晰,易于學(xué)習與理解,下面請大家跟著(zhù)小編的思路慢慢深入,一起來(lái)研究和學(xué)習“ORACLE和MYSQL怎么互相導入數據”吧!
只是一個(gè)列子和方法具體的選項按需求添加
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;
--關(guān)閉游標
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
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站