Why is this happening in `Enable Query Optimization` Hi all,
db2 => create table emp(empno int not null primary key, \
db2 (cont.) => sex char(1) not null constraint s_check check \
db2 (cont.) => (sex in ('m','f')) \
db2 (cont.) => not enforced \
db2 (cont.) => enable query optimization)
DB20000I The SQL command completed successfully.
db2 => insert into emp values(1,'m')
DB20000I The SQL command completed successfully.
db2 => insert into emp values(2,'f')
DB20000I The SQL command completed successfully.
db2 => insert into emp values(2,'q')
db2 => insert into emp values(3,'q')
DB20000I The SQL command completed successfully.
db2 => select * from emp
EMPNO SEX
----------- ---
1 m
2 f
3 q
3 record(s) selected.
db2 => select * from emp where sex = 'q'
EMPNO SEX
----------- ---
0 record(s) selected.
db2 => select * from emp where sex <> 'm'
EMPNO SEX
----------- ---
2 f
3 x
2 record(s) selected.
I have add the enable query optimization clause.. But how come the
last query is showing records with sex x??
According to doc "The ENABLE QUERY OPTIMIZATION keyword also allowed
DB2 to use this constraint information when optimizing SQL
statements."
I am using db2 8.1
Thiru.
WantedToBeDBA. |