export db v1.01 start to support microsoft sql sever 2005 support DB2 & MySql & MsSql The file type exported can be csv or sql support more than one table data export at one time latter other database may be will support, thanks for all of your supp
本文实例讲述了mysql实现查询结果导出csv文件及导入csv文件到数据库操作。分享给大家供大家参考,具体如下:
mysql 查询结果导出csv文件:
select logtime, operatingsystem, imei
from GameCenterLogs
where
operatingsystem >= 1 and operatingsystem <=3
group by operatingsystem,imei
into outfile '/tmp_logs/tm
脚本内容如下: 代码如下: set linesize 3000; set heading off; set feedback off; set term off; set pagesize 0; set trimspool on; spool a.csv; select c1_name||’,’||c2_name from dual; select c1||’,’||c2 from tbtest spool off;
您可能感兴趣的文章:把CS
方案有很多种,我这里简单说一下:
1. into outfile
代码如下:
SELECT * FROM mytable
INTO OUTFILE ‘/tmp/mytable.csv’
FIELDS TERMINATED BY ‘,’
OPTIONALLY ENCLOSED BY ‘”‘
LINES TERMINATED BY ‘\n’;
在我使用过程中发现一个特别严重问题,这里面不能插入查询条件,比如where这些,也就是说只能整表导出,不知道是不是我的写法有问
导入csv: 代码如下:load data infile ‘/test.csv’ into table table_name fields terminated by ‘,’ optionally enclosed by ‘”‘ escaped by ‘”‘ lines terminated by ‘\r\n’ ignore 1 lines;
导csv: 代码如下:SELECT * INTO OUTFILE ‘/test.csv’ FIELDS TERMINATED BY ‘,’ OPTIO