0

我是 postgresql 的新手,刚开始使用它。我正在尝试将文件加载到表中并面临一些问题。

示例数据 - 文件 file1.RPT 包含以下格式的数据

"Bharath"|Kumar|Krishnan
 abc"|def|ghi
 qwerty|asdfgh|lkjhg

下面是使用的加载脚本

LOAD CSV
INTO table1
....
WITH truncate,
fields optionally enclosed by '"',
fields escaped by '"'
fields terminated by '|'
....

但是,上面的脚本不起作用,并且没有将任何数据加载到表中。我不确定这里有什么问题。我的理解是必须成功加载第一行数据(因为我已经给出了可选的括起来)并且第二行也必须加载(因为我试图逃避双引号)。

请求帮助以得到相同的纠正。

谢谢你。

4

2 回答 2

0

我们不能转义并选择性地引用相同的字符。如果双引号将成为数据的一部分,则可以使用不包含字段的选项将其忽略。默认选项是可选用双引号括起来的字段。

于 2018-02-12T18:59:11.047 回答
0

Apparently, you're not escaping the quote in the second row, because either you must use a backslash (or another quoting character) before:

abc\"|def|ghi

or you should enclose the entire line with quote

another alternative is to accept to have quotes in the first field, then you should use the following:

fields not enclosed

in your load script

于 2018-10-31T14:20:34.317 回答