最近在研究使用mycat,其中有使用批量數據導入,簡單記錄一下使用方式。mysql
查看系統屬性sql
mysql>show variables like '%secure%'; +--------------------------+-----------------------+ | Variable_name | Value | +--------------------------+-----------------------+ | require_secure_transport | OFF | | secure_auth | ON | | secure_file_priv | /var/lib/mysql-files/ | +--------------------------+-----------------------+ 3 rows in set (0.03 sec)
咱們導出的數據必須制定爲/var/lib/mysql-files/
,oracle也有相似的設置。vim
load data 必須指明表,例如我導出表t_card_validate_info2的數據,命令以下oracle
mysql>use ncc; mysql> select * from t_card_validate_info_m into outfile '/var/lib/mysql-files/t_card_validate_info.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n'; Query OK, 24892 rows affected (0.53 sec)
查看目錄/var/lib/mysql-files/
ui
root@8d3d654c37ac:/# ls /var/lib/mysql-files/ t_card_validate_info.txt
vim/cat能夠看到純記錄。3d
導入code
load data local infile '/var/lib/mysql-files/t_card_validate_info1.txt' INTO TABLE t_card_validate_info FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (cert_id, merchant_id, cust_no, cust_name, id_type, id_no, bank_card_type, bank_card_no, cvv, expiry_date, mobile_no, bank_code, bank_name, valid_type, remark, channel_id, channel_name, channel_merchant_id, channe hannel_standby2, channel_standby3, channel_standby4, return_code, return_msg, standard_code, standard_msg, sms_status, verify_status, valid_method, version, create_datetime, update_datetime, standby1, standby2, standby3, standby4, standby5, standby6);