将 mysql 表导出到 csv
我正在使用 sqlyog 并尝试将表的数据导出到 csv。我用于导出的设置是:
- 转义符: \ 行
- 终止符: \r\n
- 可变长度: 字段终止符: , , 封闭的字段: " 可选
问题是我的某些字段包含带有 " 的数据,例如会议地点为“Plaza hotel”。这会“损坏”数据并且字段不会按应有的方式显示。有什么办法可以解决这个问题吗?
非常感谢!
I am using sqlyog and trying to export the data of a table to csv. The settings I use for exporting are:
- Escaped by: \
- Lines terminated by: \r\n
- Variable length: Fields terminated by: , ,Fields enclosed by: " Optionally
The problem is that some of my fields contain data with ", e.g. The place of the meeting is at "Plaza hotel". This "corrupts" the data and the fields are not shown as they should be. Is there a way I can fix this?
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 MySQL 文档: http://dev .mysql.com/doc/refman/5.0/en/string-syntax.html#character-escape-sequences
因此使用双引号作为“转义字符”。
Refer MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html#character-escape-sequences
So use Double-quotes as "Escape Character".
假设我们有这样的查询:
因此,如果我们需要将此数据导出到 csv 文件中,那么使用以下查询我们可以执行以下操作:
Suppose we have a query like:
So if we need to export this data into a csv file then using below query we can do: