,項目中須要將sqlserver數據導出成txt,而後再將數據導入到oracle中,我用到了sqlldr方法,還不錯哦sql
1.建立測試表
-- Create table
create table TEST
(
HEAD_ID NUMBER(6) not null,
HEAD VARCHAR2(20) not null,
AREA_CODE VARCHAR2(9) not null,
HEAD_LENGTH NUMBER(2),
COMMENTS VARCHAR2(60)
);
2.建立測試文件,文件名爲result.txt,文件內容以下
1,021,021,3,上海
2,025,025,3,南京
3,0410,410,4,鐵嶺
4,0512,512,4,蘇州
5,139159,025,7,南京
6,123456789,025,9,testoracle
3.建立ctl文件,文件名爲result.ctl,內容以下:
Load data infile 'result.txt'
Append into table test
(
head_id char(6) terminated by ',',
head char(20) terminated by ',',
area_code char(9) terminated by ',',
head_length char(2) terminated by ',',
comments char(60) terminated by ','
)ide
4.建立批處理文件,文件名爲load_data.bat,內容以下sqlserver
sqlldr userid=username/userpass@SID control=result.ctl log=result.log測試
pausecode
5.把上述文件放到同一個目錄裏面,執行load_data.bat文件就OK了。server
經過測試沒問題哦it