I have set a serializable transaction isolation lock for a transaction.But i am observing some results which are not expected.
My query is
update tabl1 set col2 = 10 where col1 > 10 and col1 < 20
Here col1 is primary key.Here rows with col1 having value 10,11,12....19,20 are locked for update/insert. In where condition i have given conditions as col1>10 and col1<20 but still rows having col1=10 and col1=20 gets locked.
If i give
update tabl1 set col2 = 10 where col1 => 10 and col1 <= 20
then rows with col2 having values from 9 to 21 gets locked.So why col1 having 9 and 21 gets locked here?
For the below query full table gets locked.Here col3 is a non-primary column.Can't i set lock if the column in where condition is not a primary key?
update tabl1 set col2 = 10 where col3 > 10 and col3 < 20