How to search new line char in oracle table?

后端 未结 4 1610
走了就别回头了
走了就别回头了 2021-01-08 00:26

I have an issue with a file that\'s created from data (in format of bytes) returned from the database.
the problem is that there is a few newlines in the file.
i wou

相关标签:
4条回答
  • 2021-01-08 00:49

    Using the CHR function to look for the ASCII value:

    select *
    from your_table
    where instr(your_text_col, chr(10)) > 0;
    

    If you want to search for carriage returns, that would be chr(13).

    0 讨论(0)
  • 2021-01-08 01:03

    Depending on the platform, a newline will generally either be a CHR(10) (Unix) or a CHR(13) followed by a CHR(10) (Windows). There are other options for other more esoteric platforms, but 99.999% of the time, it will be one of these two.

    You can search the data in a column looking for one or both characters

    SELECT instr( column_name, CHR(10) ) position_of_first_lf,
           instr( column_name, CHR(13) || CHR(10) ) position_of_first_cr_lf
      FROM table_name
     WHERE instr( column_name, CHR(10) ) > 0
    
    0 讨论(0)
  • 2021-01-08 01:04

    This worked the best for me.

    select * from label_master where regexp_like (text, chr(10));

    0 讨论(0)
  • 2021-01-08 01:08

    You can write something like:

    SELECT id
      FROM table_name
     WHERE field_name LIKE '%'||CHR(10)||'%'
    ;
    

    (|| is the concatenation operator; CHR(10) is the tenth ASCII character, i.e. a newline.)

    0 讨论(0)
提交回复
热议问题