导出:
SELECT * INTO OUTFILE 'e:/test.txt' 数据保存的位置
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ' " ' 字段之间的分隔符,字段用双引号引起来(数字类型除外)
LINES TERMINATED BY '\n' 每行用换行符结束
FROM DBNAME.TABLENAME
导入:
LOAD DATA INFILE 'e:/test.txt'
INTO TABLE DBNAME.TABLENAME
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ' " '
LINES TERMINATED BY '\n';
使用这种方式比SQL导出文件更加紧凑,更易于用命令行工具生成,但是它最大的优点还是备份和还原的速度。
来源:oschina
链接:https://my.oschina.net/u/156008/blog/70631