char类型关联

SQL> create table a1(id int,name char(10));

Table created.

SQL> create table a2(id int,name char(10));

Table created.

SQL> insert into a1 values(1,'a');

1 row created.

SQL> commit;

Commit complete.

SQL> insert into a2 values(100,'a'||CHR(13));

1 row created.



SQL> select dump(name) from a1;

DUMP(NAME)
--------------------------------------------------------------------------------
Typ=96 Len=10: 97,32,32,32,32,32,32,32,32,32



SQL> select length(name) from a1;

LENGTH(NAME)
------------
	  10


SQL> select dump(name) from a2;

DUMP(NAME)
--------------------------------------------------------------------------------
Typ=96 Len=10: 97,13,32,32,32,32,32,32,32,32

SQL> select length(name) from a2;

LENGTH(NAME)
------------
	  10


SQL> select * from a1,a2
  2  where a1.name=a2.name;

no rows selected

SQL> select * from a1,a2
  2  where a1.name=replace(a2.name,CHR(13),'');

no rows selected

看来char 用这种方式是没法替换回车符的,原因:
SQL> select length(replace(a2.name,CHR(13),'')) from a2;
LENGTH(REPLACE(A2.NAME,CHR(13),''))
-----------------------------------
      9
变成9位了,当然和a1.name 10位关联不上
SQL> select * from a1,a2 2 where a1.name=replace(a2.name,CHR(13),CHR(32)); ID NAME ID NAME---------- ---------- ---------- ---------- 1 a 100 aSQL> select * from a1,a2 2 where a1.name=replace(a2.name,CHR(13),''||' ');ID NAME ID NAME---------- ---------- ---------- ---------- 1 a 100 a需要在补上一个空格


 

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/3797967.html