昨天数据库重启以后
SQL> SELECT * FROM V$VERSION ;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
PL/SQL Release 9.2.0.1.0 - Production
CORE
9.2.0.1.0
Production
TNS for Solaris: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
SQL> SELECT * FROM TEST ;
A
-----
AA
SQL> DESC TEST
Name TypeNullable Default Comments
---- ------- -------- ------- --------
ACHAR(5) Y
SQL> SELECT * FROM TEST WHERE A LIKE 'AA' ;
A
-----
SQL>
不对。
还是这个表:
SQL> desc test
Name
Null?Type
------------------------------- -------- ----
A
CHAR(5)
SQL> select * from test
2/
A
-----
AA
SQL> select * from test where a = 'AA' ;
A
-----
AA
对于 char类型字符串的等于的判定,oracle总是会去掉 末尾的空格的
SQL> create table test (a varchar2(5),b char(5));
Table created.
SQL> select ascii(' ') from dual;
ASCII('')
----------
32
SQL> insert into test values('a'||chr(32),'b');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test where a = 'a';
no rows selected
SQL> select * from test where a = 'a'||chr(32);
A B
----- -----
a b
SQL>select * from test where b = 'b';
A B
----- -----
a b
SQL>select * from test where blike 'b';
no rows selected
SQL> create table aa (a char(5));
Table created.
SQL> insert into aa values('aa');
1 row created.
SQL> select * from aa where a like 'aa';
A
-----
aa
SQL> commit;
Commit complete.
SQL> select * from aa where a like 'aa';
A
-----
aa