I ran into a problem with the script interface, which should export the contents of some ORACLE database table to a CSV file, followed by import of these CSVs into the MYSQL database.
STEP1: Export SQLPlus to CSV
set headsep off
set heading off
set term off
set echo off
SET RECSEPCHAR \n
set pagesize 0
set linesize 0
trimspool on
SET FEEDBACK OFF
spool as_ex_feature.csv
select '"AS'||'"|"'||feature_group||'"|"'||feature_desc||'"|"
||feature_order||'"|"'||prod_code||'"'
from MYVIEW WHERE MYCONDITIONS;
spool off;
-> this step generates a CSV file, but the format seems to be wrong, since I can find the carriage return in the output. You will also see in STEP2 that we define the value "ENCLOSED BY", how can I get the one that is included in the export format (it seems that this is not the case now).
STEP 2: loading MYSQL
LOAD DATA INFILE 'mycsvfile' REPLACE INTO TABLE `mt_feature`
FIELDS TERMINATED BY '|'
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n';
This script had to be rebuilt for some technical reasons, and the Mysql part was not changed and works fine with the corresponding CSV file for import.
, , SQLPlus, , . , ?
, , , ...
Script oracle 10g, Linux, Mysql 4.x
!