使用 SQL 'like' 子句在 Oracle DB 中搜索换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3868384/
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
Searching for newlines in a Oracle DB using SQL 'like' clause
提问by awied
I'm trying to see if a particular column in a table in my Oracle database has any strings which contain a newline character, so a wildcard, a newline, and another wildcard.
我正在尝试查看我的 Oracle 数据库中表中的特定列是否包含任何包含换行符的字符串,例如通配符、换行符和另一个通配符。
I've tried the like command and a combination with CHR(10) and tried escaping the newline itself, but to no avail. What would be the proper way to detect a newline in somewhere within a string?
我已经尝试过类似命令以及与 CHR(10) 的组合并尝试转义换行符本身,但无济于事。在字符串中的某处检测换行符的正确方法是什么?
Thanks!
谢谢!
回答by Alex Poole
like '%'||chr(10)||'%'
ought to work.
like '%'||chr(10)||'%'
应该工作。
回答by jle
select * from yourTable where InStr(yourCol, Chr(10))>0
would work
select * from yourTable where InStr(yourCol, Chr(10))>0
会工作