Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991

Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993
Question 7: Which of the following statements abort, if the mysql client was started with –safe-updates? – MySQL Question of the Day

Skip to content

By urs in mysql questions

 

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 ]
 

Tags: , ,

Comment Feed

One Response


  1. 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

You must be logged in to post a comment.