使用SQL * Loader - 我怎么能忽略与特定charactre某些行(SQL*Loader

2019-10-20 07:03发布

如果我有一个CSV文件,该文件是按以下格式

"fd!","sdf","dsfds","dsfd"
"fd!","asdf","dsfds","dsfd"
"fd","sdf","rdsfds","dsfd"
"fdd!","sdf","dsfds","fdsfd"
"fd!","sdf","dsfds","dsfd"
"fd","sdf","tdsfds","dsfd"
"fd!","sdf","dsfds","dsfd"

是否有可能排除其中第一列具有字符串的结尾感叹号任何行。 也就是说,它应该只加载以下行

"fd","sdf","rdsfds","dsfd"
"fd","sdf","tdsfds","dsfd"

谢谢

Answer 1:

按照基于一个条件载入记录的SQL * Loader控制文件参考(11克)的部分:

“你可以选择加载或使用WHEN子句测试中记录的条件丢弃逻辑记录。”

所以,你需要这样的:

LOAD DATA ... INSERT INTO TABLE mytable   WHEN mycol1 NOT LIKE '%!' 
(mycol1..  ,mycol2 ..)

但是,LIKE操作不可用! 你只有=!=

也许你可以尝试外部表代替。



Answer 2:

我会坚持在桌子上的约束,而只是让他们被拒绝。 加载后也许删除它们。 或UNIX的“grep -v”来清除出来的文件。



文章来源: SQL*Loader - How can i ignore certain rows with a specific charactre