本文目录一览:
mysql怎么导出csv格式数据文件
mysql导出csv格式数据文件需要使用mysqldump工具,具体方法如下:
1 登陆mysql数据库:
2 查询原始要导出的数据
3 编写导出语句:
SELECT *
FROM cus_tbl
WHERE 1
INTO OUTFILE 'c:/tmp/t1.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
4 导出后:
如何把mysql数据库导出到csv文件
由于工作需要,经常需要将mysql数据库中的数据导出到excel表格,或者需要将excel表格数据导入到mysql数据库,我的方法是先将它们都转换成一种中间数据格式csv(execl数据可以直接导出为csv格式,csv格式也可以直接用excel打开)。下面介绍一下操作步骤:
csv导入mysql
load data infile 'C:\\Users\\UserName\\Desktop\\test.csv'
into table `table`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
mysql导入csv
select * from `table`
load data infile 'C:\\Users\\UserName\\Desktop\\test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
如果乱码,可用相关编辑器打开.csv文件,另存为utf-8的csv
如何将csv导入mysql和mysql导出csv
先将它们都转换成一种中间数据格式csv(execl数据可以直接导出为csv格式,csv格式也可以直接用excel打开)。下面介绍一下操作步骤:
csv导入mysql
load data infile 'C:\\Users\\UserName\\Desktop\\test.csv'
into table `table`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
mysql导入csv
select * from `table`
load data infile 'C:\\Users\\UserName\\Desktop\\test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
如果乱码,可用相关编辑器打开.csv文件,另存为utf-8的csv