table1 was created like this: create table table1 (id int primary key,name varchar(32)); insert into table1 values (1,'a'),(2,'b'),(3,'zeh');
(Find all correct answers)
a) delete from table1 where id+1=10; b) update table1 v1 set v1.name='v' where abs(id)=12; c) update table1 v1 set v1.name='v' where id between 1 and 999999 and name='f';
[ Tables and Indexes (15%) - Indexes ]
Answers:
a b
When a function is used on a column, its corresponding index cannot be used.
c works, because the index on id can be used.
mysql> delete from table1 where id+1=10;
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
mysql> update table1 v1 set v1.name='v' where abs(id)=12;
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column