Netezza:需要帮助来理解 nzload 执行中的 lfinstring 选项



我正在使用Netezza db,我需要帮助来理解nzload命令中的lfinstring选项。

有人可以解释一下上述选项如何在 nzload 执行期间与示例一起使用。

下面是示例: 猫测试.sql_旧

"so this is a <LF>
test not as last char of the string"
"and this is a <LF> as last char of the string
"

nzload 命令

nzload -db TEST -t tab1  -nullValue '..' -delim '0x1e' -ctrlChars -timeDelim '.' -dateTimeDelim '-'  -df /test/test.sql_old -lfinstring

电流输出:

nzsql TEST -c "select * from TAB1"  
COL1
------------------------------------------------------------------------------------------------------
"so this is a <LF>
"and this is a <LF> as last char of the string
test not as last char of the string"
"
(4 rows) 

预期输出:

仅 2 行

第一行

so this is a test not as last char of the string

第二行

and this is a as last char of the string

我们可以使用 -lfinstring 选项或任何其他选项获得以上的输出,或者它是不可能的吗?

我想这个例子说了大多数需要知道的:

以下命令指定嵌入的换行符值 此外,记录分隔符被视为实际数据:

nzload -u admin -pw password -host nzhost -db emp -t name -df /tmp -lfinString

我在这个 IBM 在线手册页面上找到了它

我希望这有所帮助,否则请指定:)

下面是如何使用 lfinstring 的示例

[nz@netezza ~]$ cat test.txt
so this is a test
not as last char of the string|row1
and this is a as last char of the string
|row2
[nz@netezza ~]$ nzsql -d testdb -c "d lf_test"
Table "LF_TEST"
Attribute |         Type          | Modifier | Default Value 
-----------+-----------------------+----------+---------------
COL1      | CHARACTER VARYING(50) |          | 
COL2      | CHARACTER VARYING(10) |          | 
Distributed on random: (round-robin)
[nz@netezza ~]$ nzload -db testdb -df test.txt -t lf_test -lfinstring  -delim '|'
Load session of table 'LF_TEST' completed successfully
[nz@netezza ~]$ nzsql -d testdb -c "select * from lf_test order by col2"
COL1                       | COL2 
--------------------------------------------------+------
so this is a test
not as last char of the string | row1
and this is a as last char of the string
| row2
(2 rows)

请注意,换行符仍在数据中,因此它呈现到屏幕上看起来像四行,但您可以看到它实际上是 2 行。

现在,让我们参考 lfinstring 选项的实际文档,可以在此处找到,注意粗体部分。

LFINSTRING 选项

指定是否将同时作为记录分隔符的嵌入换行符值视为实际数据。 可接受的值为真或假。默认值为 false。不要在值两边加上引号。

默认情况下,换行符值是记录分隔符。您可以使用 -recDelim 选项将记录分隔符更改为另一个值。 如果 LFinString 选项的值为 true,并且记录分隔符是换行符值,则无论"填充记录"选项的设置如何,都将应用以下行为:

如果换行符值
  • 不在字段的最后一条记录中,则换行符值将被视为实际数据。
  • 如果换行符值
  • 位于字段的最后一条记录中,则换行符值将被视为记录分隔符,除非您对其进行转义。

LFinString 选项仅适用于数据加载。它对数据卸载没有影响。固定长度格式不支持此选项。

我相信最后两个粗体部分是排版错误并且是颠倒的。 它们应为:

如果换行符值
  • 不在记录的最后一个字段中,则换行符值将被视为实际数据。
  • 如果换行符值位于记录的最后一个字段中,则换行符值将被视为记录分隔符,除非您对其进行转义。

最新更新