很奇怪,请帮忙测一下

[复制链接]
查看11 | 回复9 | 2008-1-21 16:50:24 | 显示全部楼层 |阅读模式
昨天数据库重启以后
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>
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
没问题呀,很正常么.
你既然是char(5),
那么存储的就是
'AA '.
AA后面有三个空格.
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
不对。
还是这个表:
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
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
??
select a,length(a) from test;
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
拜托你能贴一下你的测试结果吗?
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
who can explain this
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
我817和9204下都测过,没遇到你这个现象嘛
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
对于 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
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
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
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
嘿嘿,我的数据库有毛病了。自从昨天重起以后应用出现问题,查问题查到这里。
biti的好像也不太对(最后的一个查询)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行