mysql导入csv格式数据
2015-10-27 15:11
561 查看
/article/9703806.html
MySQL中导出CSV格式数据的SQL语句样本如下:
Sql代码
select * from test_info
into outfile '/tmp/test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
[sql] view
plaincopy
select * from test_info
into outfile '/tmp/test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
MySQL中导入CSV格式数据的SQL语句样本如下:
Sql代码
load data infile '/tmp/test.csv'
into table test_info
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
[sql] view
plaincopy
load data infile '/tmp/test.csv'
into table test_info
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
里面最关键的部分就是格式参数
Sql代码
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n'
[sql] view
plaincopy
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n'
若编码有误可以将csv文件用notepad++打开并转存为utf-8编码
--CHARACTER SET :mysql字符集,一定要加上,免去乱码麻烦
--INTO TABLE :导入到哪个表
--FIELDS TERMINATED BY :以什么作为分割符
-- ENCLOSED BY :被什么包围
字段之间以逗号分隔,数据行之间以\r\n分隔;
字符串以半角双引号包围,字符串本身的双引号用两个双引号表示。
MySQL中导出CSV格式数据的SQL语句样本如下:
Sql代码
select * from test_info
into outfile '/tmp/test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
[sql] view
plaincopy
select * from test_info
into outfile '/tmp/test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
MySQL中导入CSV格式数据的SQL语句样本如下:
Sql代码
load data infile '/tmp/test.csv'
into table test_info
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
[sql] view
plaincopy
load data infile '/tmp/test.csv'
into table test_info
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';
里面最关键的部分就是格式参数
Sql代码
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n'
[sql] view
plaincopy
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n'
若编码有误可以将csv文件用notepad++打开并转存为utf-8编码
--CHARACTER SET :mysql字符集,一定要加上,免去乱码麻烦
--INTO TABLE :导入到哪个表
--FIELDS TERMINATED BY :以什么作为分割符
-- ENCLOSED BY :被什么包围
字段之间以逗号分隔,数据行之间以\r\n分隔;
字符串以半角双引号包围,字符串本身的双引号用两个双引号表示。
相关文章推荐
- mysql中模糊查询的四种用法介绍
- mysql配置文件的常见修改
- mycat分布式mysql中间件(数据库切分概述)
- 导入mysql数据太大导入失败解决方案
- 处理mysql启动报错Table 'mysql.plugin' doesn't exis
- Ubuntu下安装mysql
- 解决本地启用XAMPP – MySQL shutdown unexpectedly问题
- mysql一些函数常见的用法(group by、order by、....)(1)
- wdDNS智能DNS(bind + mysql + web)
- mysql之触发器trigger
- mysql锁表机制分析
- mysql 提示 Writing to net
- MySQL-Proxy之读写分离
- mysql explain type连接类型示例
- MySQL日期相关函数
- mysql索引
- mysql查看表结构命令
- MySQL命令行远程链接服务器
- MySQL
- mac系统OS X10.10版本安装最新5.7.9mysql的方法