A MySQL command- line client is started with safe updates disabled.
Mysql – -safe – updates=0
What happens when you execute an UPDATE statement without a WHERE clause?
A.
Results in an error
B.
Updates every row in the specified table(s)
C.
Results in – -safe-updates being enabled automatically
D.
Causes a syntax error
Explanation:
Reference:
http://justalittlebrain.wordpress.com/2010/09/15/you-are-using-safe-update-mode-and-youtried-to-update-a-table-without-a-where-that-uses-a-key-column/
correct is A
Correct is B. A would be correct if you had safe updates enabled.
B
SET sql_safe_updates=0;
CREATE TABLE t1 (i INT, j INT);
INSERT INTO t1 VALUES(1,1),(2,3);
update t1 set i = 3;
SELECT * FROM t1;
i, j
‘3’, ‘1’
‘3’, ‘3’
B is correct.
B
B
sql_safe_updates or –safe-updates(when you start the client) option prevents row modifications, such as update or delete that do not specify the KEY values.
DELETE FROM tb WHERE key = 1; will be deleted
DELETE FROM tb WHERE col = 1; will not be deleted if the col does not have key
when you set sql_safe_updates to true/1
B