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 4: Which of the following statements will abort, if the mysql client was started with –safe-updates? – MySQL Question of the Day

Skip to content

By urs in mysql questions
The table "table1" has been created like follows:

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) update table1 set id=4 where name='zeh';
b) select * from table1;
c) delete from table1 where id=5;
d) delete from table1 where name='zeh';
 

[ The mysql Client Program (10%) - Using the --safe-updates Option ]

 

Tags: , ,

Comment Feed

One Response


  1. Answers:

    a d

    There is no index on “name”, so both statements having only name in the where-clause will abort.

    mysql> update table1 set id=4 where name='zeh';
    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> delete from table1 where name='zeh';
    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.