oracle SQLLDR -- 从管道分隔的 txt 中选择性加载

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5013691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:46:05  来源:igfitidea点击:

SQLLDR -- selective loading from pipe delimited txt

oraclesql-loader

提问by iwan

I am looking for a way to do selective loading using SQLLDR. The source file is in "pipe delimited" format.

我正在寻找一种使用 SQLLDR 进行选择性加载的方法。源文件采用“管道分隔”格式。

I know there is a way for this if the source is in a predefined position. It is explained here, by using WHEN & POSITION keywords.

我知道如果源位于预定义的位置,则有一种方法。这说明这里,通过使用WHEN和位置的关键字。

What could I do if the source file is "pipe or tab" delimited?

如果源文件以“管道或制表符”分隔,我该怎么办?

回答by a_horse_with_no_name

I am not sure what you mean with "selective loading"?

我不确定“选择性加载”是什么意思?

But ify you are only asking how you can load a file where each column is delimited with a pipe, then use the option FIELDS TERMINATED BY '|'in the control file.

但是如果你只是问你如何加载一个文件,其中每列都用管道分隔,然后使用FIELDS TERMINATED BY '|'控制文件中的选项。

See the chapter "Variable Record Format" in the SQL*Loader manual for more details and examples:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_concepts.htm#sthref476

有关更多详细信息和示例,请参阅 SQL*Loader 手册中的“变量记录格式”一章:http:
//download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_concepts.htm#sthref476

回答by Delvin

Depending on which version of the SQLLDR version you are using, you can use the keyword FILLER to skip a field from the file.

根据您使用的 SQLLDR 版本,您可以使用关键字 FILLER 跳过文件中的字段。

The below instruction will skip the second field in the file.

以下指令将跳过文件中的第二个字段。

LOAD DATA
TRUNCATE INTO TABLE T1
FIELDS TERMINATED BY ','
( field1,
  field2 FILLER,
  field3
)

回答by Leela

LOAD DATA
INFILE 'c:\myfile.txt'  
TRUNCATE INTO TABLE T1
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS (field1, field2 , field3, field4)