查询结果输出到文件
SELECT * FROM tablename INTO OUTFILE '/tmp/tablename.txt';
使用tee将屏幕输出到文件
mysql>tee /home/neo/screen.txt mysql>select * from user; mysql>exit
SELECT * INTO OUTFILE '/home/mark/Orders.txt' FIELDS TERMINATED BY = ',' FROM Orders WHERE Order_Date >= '2000-01-01'
LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
SELECT * INTO OUTFILE '/tmp/products.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM products
LOAD DATA LOW_PRIORITY LOCAL INFILE 'C:\\hx.csv' IGNORE INTO TABLE `tmp`.`creditlog` CHARACTER SET gbk FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\r\n' (`ctime`, `login`, `mode`, `type`, `prevavailcredit`, `change`, `newavailcredit`, `comment`);
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。