SQL Loader ctl 文件 - 如何跳过列
假设我的数据库有 4 列:
Column1, Column2, Column3, Column4
我的数据文件是 CSV 文件(逗号分隔,列长度未知):
xxx,yyy,zzz,000
a,bb,ccccc,ddddddd
1,2,3,4
CTL 将是:
LOAD DATA
INTO TABLE "TABLE"
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
Column1,
Column2,
Column3,
Column4
)
我想跳过 Column3,我该怎么做?我了解 FILLER
但它不适用于旧的 Oracle 版本。
Let's say in my database 4 columns:
Column1, Column2, Column3, Column4
My data file is CSV file (comma delimited, length of column is unknown):
xxx,yyy,zzz,000
a,bb,ccccc,ddddddd
1,2,3,4
The CTL will be:
LOAD DATA
INTO TABLE "TABLE"
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
Column1,
Column2,
Column3,
Column4
)
I want to skip Column3, how can I do that? I know about FILLER
but it doesn't work for old oracle versions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果可以的话,只需使用 shell 工具删除第三列即可。这就是有效。
例如,使用
awk
:或使用
sed
:(您可以选择其他几个工具(例如
cut
...)If that's an option just drop the third column with a shell tool. That's just works.
E.g. with
awk
:Or with
sed
:(and you can pick several other tools (e.g.
cut
...)我真的不知道早期版本是否支持这一点,但在以后的版本中,您可以使用 SQL 运算符:
...无论数据文件中是否有值,都会将
Column3
设置为 null 或不。I really don't know if this is supported in early versions, but in later ones you can user an SQL operator:
... which will set
Column3
to null whether it has a value in the data file or not.一种方法是使用中间表或加载表,如下所示:
然后调用一个存储过程来处理主表的填充,如下所示:
One approach would be to use an intermediate or load table, like so:
and then call a stored proc afterwards that handles the population of your main table, something like this: