开发者

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

开发者 https://www.devze.com 2022-12-08 04:33 出处:网络
I need to find the rows where a certain column contains line feed. This does not work: select * from [table] where [column] like \'%\\n开发者_JAVA技巧%\'

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

This does not work: select * from [table] where [column] like '%\n开发者_JAVA技巧%'

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

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

If not, what is the solution in Oracle?


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

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


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

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


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

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


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


Alternatively:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消