mysql -uroot -p -e " SELECT id, appName, appVersion FROM test.ua_message INTO OUTFILE '/tmp/ua_message.tsv' "
可修改数据格式,导出指定字段 csv
1
mysql -uroot -p -e " SELECT id, appName, appVersion FROM test.ua_message INTO OUTFILE '/tmp/ua_message.tsv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' "
导入操作
忽略错误导入,如忽略逐渐冲突
-f 参数
1
mysql -uroot -p -f dbname < /data/tmp/tablename-delta-0304.sql
导入 csv、tsv
1 2 3
LOAD DATA INFILE '/tmp/data.csv' INTO table `tablename` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
LOAD DATA INFILE '/tmp/data.tsv' INTO table `tablename` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n';
合并导入
将 t1 表与 t2 表数据按照主键合并后,导入到新表:
1
INSERT INTO `tablename_v1` (id, c1, c2) select t1.id, t1.c1, t2.c2 from t1, t2 where t1.id = t2.id