我应该如何转义 Oracle SQLLoader (sqlldr) 导入的引号和换行符?
首先:是的,我了解 CONCATENATE 和 CONTINUEIF,但我可能不够聪明,无法理解文档。 我不“明白”他们如何解决我的问题。 谢谢...
我必须创建一个文件,以便通过 sqlldr 导入到 Oracle DB 中。
这些列需要用“~”分隔(不要问。)在创建文件文件时,我对 sqlldr 在引号和换行符方面的行为方式有一些担忧。
如果一个简单的行包含列值:
One, Hello~World I "Like" you, and Three
我应该如何将其输出到文件中? 我的第一个猜测是,
One~"Hello~World I "Like" you"~Three
我想用 CTL 文件中指定的 FieldS TERMINATED BY "~" OPTIONALLY ENCLOSED BY '"' 进行导入会很容易。我不知道如何处理的是当我创建时围绕 Like 的引号文件是否应该另外转义
? 这些字段可能包含换行符。 如果写出“原始”,它将变成
one~Line
Break~three
CTL 文件中是否有一个选项可以用来将它们“缝合”在一起? 中断可能发生在不同的列中,并且每个记录或列可能有多个中断。
提前致谢!
FIRST: Yes, I know about CONCATENATE and CONTINUEIF, but I might not be smart enough to understand the documentation. I don't "get" how they solve my problem. Thank you...
I am in the position of having to create a file for importing into an Oracle DB by way of sqlldr.
The columns are required to be delimited by "~" (Don't ask.) In creating the file file, I have a few concerns about the way sqlldr behaves in respect to Quotes and Newlines.
If a simple row is to contain the column values:
One, Hello~World I "Like" you, and Three
How should I output this to the file? My first guess is
One~"Hello~World I "Like" you"~Three
I imagine it would be easy to import with FIELDS TERMINATED BY "~" OPTIONALLY ENCLOSED BY '"' specified in the CTL file. What I don't know how to handle are the quotes around the Like when I create the file. Should those be additionally escaped? How?
Additional Bonus Question:
The fields may contain line-brakes. If written out "raw" it would turn into
one~Line
Break~three
Is there an option in the CTL file that I can use to "stitch" these back together? The break may occur in different columns and there may be more than one break per record, or column.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些实验,这就是我发现的:
使用时,
在 CTL 文件和表结构中
处理引号和分隔符的正确方法是
,如果数据包含分隔符,请引用整个值并将值中的引号替换为 2引号。
至于换行符,我将在另一个问题中提出。
After some experimentation this is what I discovered:
While using
in the CTL file and a table structure of
The right way to handle quotes and delimiters are
So, If the data contains the delimiter, quote the whole value and replace quotes in the value with 2 quotes.
As far as newlines go, I am going to ask that in another question.