Can anyone please explain the difference Oracle does regarding this to me?
Having an index or not on a varchar2 field gives different result when using 0 or '0' (zero that is). See the test below.
Test:
* Create a table with a varchar2 field.
create table test(aaa varchar2(5));
* Populate the table with rows containing numbers.
insert into test (aaa) values('&var_number');
* Run the queries
select aaa from test where aaa > 0 and rownum < 6;
select aaa from test where aaa > '0' and rownum < 6;
and you get the same result.
* Create an index on the table
create index test_idx on test(aaa);
* Run the queries from above again, now
the order is different.
Regards
Patrik
Having an index or not on a varchar2 field gives different result when using 0 or '0' (zero that is). See the test below.
Test:
* Create a table with a varchar2 field.
create table test(aaa varchar2(5));
* Populate the table with rows containing numbers.
insert into test (aaa) values('&var_number');
* Run the queries
select aaa from test where aaa > 0 and rownum < 6;
select aaa from test where aaa > '0' and rownum < 6;
and you get the same result.
* Create an index on the table
create index test_idx on test(aaa);
* Run the queries from above again, now
the order is different.
Regards
Patrik