janewilliams20: (geek)
janewilliams20 ([personal profile] janewilliams20) wrote2011-01-21 04:36 pm
Entry tags:

In which MySQL Workbench is just a bit too clever.

update mytable
set mycolumn = 1
where mycolumn = 0
;

Easy enough? No.

"Error Code: 1175. To disable safe mode, toggle the option in Preferences -> SQL Editor -> Query Editor and reconnect."

So I go there, and am told that safe mode prevents updates and deletes with no WHERE clause. A very good idea - but I've got a perfectly good Where clause, so what's the problem?

That error message has more than one line, and it's hard to even know the second is there to see. It says: "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column"

A key column? Well, no... and there's no way I sensibly could, for this update.

I don't want to turn off safe mode completely, nor to start & stop. But a bit of Googling comes up with an answer.

SET SQL_SAFE_UPDATES=0;
Do update
SET SQL_SAFE_UPDATES=1;

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting