SQL> select o.no from Org_Table o where o.no=0080000;
NO
---
00080000
SQL> select o.no from Org_Table o where o.no='0080000';
NO
---
SQL> select o.no from Org_Table o where o.no='00080000';
NO
---
00080000
为什么第一个结果和第二个不一样?</p>
Check execution plan of your query with filter predicates. This is what I see (assuming no
field is varchar2
):
Execution Plan
----------------------------------------------------------
Plan hash value: 2153619298
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2002 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 2002 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER("NO")=0080000)
Notice 1 - filter(TO_NUMBER("NO")=0080000)
- an implicit type conversion. Your data is compared as number, in which case 0080000 equals 80000. However, in the second case it is compared as strings (1 - filter("NO"='0080000')
), which are in this case different.