Goal
how to identify carriage return and line feed in a table
Solution
Depending on the platform, a newline will generally either be a CHR(10) (Unix) or a CHR(13) followed by a CHR(10) (Windows):
平台有异。
unix平台:chr(10)
win平台:chr(13)||chr(10)
\n is line feed(换行), \r is carriage return(回车)
\r = chr(13) 回车
\n = chr(10) 换行
You can use the CHR function to look for the ASCII value as below query:
SQL> select * from where like '%'||chr(10)||'%';
SQL> select * from where like '%'||chr(13)||'%';
SQL> select * from where like '%'||chr(13)||'%';
看了这个就比较好理解了:
用过机械式英文打字机吗?打字机头是从左往右移动的,回车就是拉回最左边,打印纸是从上向下走的,换行就是打印纸向下进一行。回车,换行是两个不同的字符。
以下代码请在sqlplus中执行:
create table tgtest3 (id number, name clob);
insert into tgtest3(id,name) values(1,'hdhd:'||chr(10)||'d');
insert into tgtest3(id,name) values(2,'hdhd:'||chr(10)||chr(13)||'d');
insert into tgtest3(id,name) values(3,'hdhd:'||chr(13)||'d');
insert into tgtest3(id,name) values(4,'hdhd:'||chr(13)||chr(10)||'d');
insert into tgtest3(id,name) values(2,'hdhd:'||chr(10)||chr(13)||'d');
insert into tgtest3(id,name) values(3,'hdhd:'||chr(13)||'d');
insert into tgtest3(id,name) values(4,'hdhd:'||chr(13)||chr(10)||'d');
select * from tgtest3 a where a.name like '%'||chr(13)||'%';
select * from oracle.tgtest3;
select 'a'||chr(13)||'b'||chr(13)||'c' name from dual;
select 'a'||chr(10)||'b'||chr(10)||'c' name from dual;
select 'a'||chr(10)||'b'||chr(10)||'c' name from dual;
select 'a'||chr(10)||'b'||chr(13)||'c' name from dual;
select 'a'||chr(13)||'b'||chr(10)||'c' name from dual;
select 'a'||chr(13)||'b'||chr(10)||'c' name from dual;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11990065/viewspace-763954/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/11990065/viewspace-763954/