以下MySQL csv导入查询术语是什么意思? [英] What do the following MySQL csv import query terms mean?

查看:59
本文介绍了以下MySQL csv导入查询术语是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于MySQL,我发现了以下查询以导入CSV文件:

For MySQL, I found the following query to import a CSV file:

LOAD DATA LOCAL INFILE '/example.csv'
INTO TABLE exampletable
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(example_field_name,example_field_city,example_field_state);

我才刚刚开始学习,所以请原谅这个琐碎的问题,但是我想知道是否有人可以用比MySQL帮助文档中更简单的方式解释以下内容:

I'm just starting to learn, so please forgive the trivial question, but I'm wondering if someone can explain the following parts of this in a simpler way than what's in the MySQL help docs:

这是什么意思?

OPTIONALLY ENCLOSED BY '"'

这是什么意思?

ESCAPED BY '\\'

下面的\ r和\ n是什么意思?

What do the \r and \n mean in the following?

LINES TERMINATED BY '\r\n'

谢谢您的帮助.

推荐答案

每个人都认为CSV文件格式很简单,而不是....您可以在

Everyone thinks CSV file format is simple, it's not.... You can read it's history on wikipedia

某些列包含分隔符.您希望将以下行加载为5列,

Some columns include the separation character. You want the following row to be loaded as 5 columns,

one, two, "three, tres, trois", four, five

以'\\'代替

如果您的数据包含引号怎么办?

ESCAPED BY '\\'

And what if your data contained a quote character?

one, two, "In France, one would say \"trois\"", four, five

以'\ r \ n'终止的行

Windows文件格式.行以两个空格字符"回车符(\ r)和"行尾(\ n).

LINES TERMINATED BY '\r\n'

Windows file format. Lines end with two white-space characters "carriage return" (\r) and "End of line" (\n).

是否曾经注意到Windows记事本无法正确打开UNIX文件?这是因为此类文件仅使用 EOL 字符终止行.所有这些都可以追溯到打字机时代,即计算和操作系统之间不兼容的文本标准.

Ever notice that windows notepad can't open unix files properly? That's because such files terminate lines with only the EOL character. All this dates back to the type-writer days of computing and incompatible text standards between operating systems.

这篇关于以下MySQL csv导入查询术语是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆