Steps:
1. Export data files from mysql
Select sender, imsi, random_code, date_format (token_create_time, '% Y % m % d % H % I % s'), date_format (last_login_time, '% Y % m % d % H % I % s'), 1 as status
From tb_sms_token where last_login_time is not null
Into outfile '/home/mysql/TB_GH_WLAN_TOKEN.dat'
FIELDS
Terminated by '$'
Escaped '\\'
LINES
Terminated by '\ r \ N'
Select sender, imsi, random_code, date_format (token_create_time, '% Y % m % d % H % I % s'), date_format (last_login_time, '% Y % m % d % H % I % s'), 1 as status
From tb_sms_token where last_login_time is not null
Into outfile '/home/mysql/TB_GH_WLAN_TOKEN.dat'
FIELDS
Terminated by '$'
Escaped '\\'
LINES
Terminated by '\ r \ N'
Each piece of data is separated by line breaks, and fields are separated by $ before.
2. If oracle cannot process fields, convert them using awk or sed in linux.
3. Use the sqlldr command of oracle to import data files. The control file content is as follows:
LOAD DATA
INFILE "/home/oracle/TB_GH_WLAN_TOKEN.dat"
APPEND
Into table GAME_HALL_TOKEN_TEMP
Fields terminated by '$'
(Id sequence (max, 1 ),
PHONE_NUMBER, IMSI, TOKEN_VALUE,
CREATE_TIME date "yyyyMMddhh24miss ",
LAST_USE_TIME date "yyyyMMddhh24miss ",
STATUS integer)
LOAD DATA
INFILE "/home/oracle/TB_GH_WLAN_TOKEN.dat"
APPEND
Into table GAME_HALL_TOKEN_TEMP
Fields terminated by '$'
(Id sequence (max, 1 ),
PHONE_NUMBER, IMSI, TOKEN_VALUE,
CREATE_TIME date "yyyyMMddhh24miss ",
LAST_USE_TIME date "yyyyMMddhh24miss ",
STATUS integer)
For more information about sqlldr usage, see oracle help.
Notes:
1. Primary Key Generation
2. Date Format Processing
3. Processing of null values
4. You can import large data volumes without creating an index in the target database. Adding an index after the import should speed up the import.