在 Oracle 中,查询换行出现的 SQL 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1560531/
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 19:12:18  来源:igfitidea点击:

In Oracle, what is the SQL to query for occurences of line feed?

sqloracle

提问by b.roth

I need to find the rows where a certain column contains line feed.

我需要找到某一列包含换行符的行。

This does not work: select * from [table] where [column] like '%\n%'

这不起作用: select * from [table] where [column] like '%\n%'

In SO, I found the solution for SQL Server: New line in Sql Query

在SO中,我找到了SQL Server的解决方案: Sql Query中的新行

But this does not work in Oracle. Is there any ANSI SQL solution? This should be a standard...

但这在 Oracle 中不起作用。是否有任何 ANSI SQL 解决方案?这应该是标准...

If not, what is the solution in Oracle?

如果没有,Oracle 中的解决方案是什么?

采纳答案by David Aldridge

An alternative to InStr() that expresses the SQL a bit more in line with the problem. IMHO.

InStr() 的替代方法,它表达的 SQL 更符合问题。恕我直言。

select * from [table] where [column] like '%'||chr(10)||'%'

回答by Vincent Malgrat

you could look for the CHR(10) character (the character for newline):

您可以查找 CHR(10) 字符(换行符):

select * from [table] where instr(column, chr(10)) > 0

回答by Juergen Hartelt

If you are working with Oracle 10g upwards, you could use

如果您使用 Oracle 10g 以上,则可以使用

select * from [table] where regexp_like([column], '\n')

回答by dpbradley

select * from tableNameHere where instr(colNameHere, chr(10)) > 0

select * from tableNameHere where instr(colNameHere, chr(10)) > 0

回答by tog22

Alternatively:

或者:

SELECT * FROM [table] WHERE column LIKE "%\n%"

\n is line feed, \r is carriage return...

\n 是换行,\r 是回车...