Sunday, April 1, 2012

MySQLWorkbench - error on DELETE, UPDATE


Sample query –
Delete from MyDB.SourceUrls

Error -
Error Code: 1175 You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

Here is the solution -
By default MySQL editor runs in Safe Mode, which means it restrict users from comprehensive delete and update operation. You need to put the where clause in your query. You can follow any of below steps to avoid the error -

1. Add SET SQL_SAFE_UPDATES=0; before your update query. -
SET SQL_SAFE_UPDATES=0;
Delete from MyDB.SourceUrls

2. Follow below steps –
MySQLWorkbench > Preferences > SQL Editor > Query Editor
uncheck option – “Safe Updates”. Forbid UPDATEs and DELETEs with no key in WHERE clause or no LIMIT clause.

No comments:

Post a Comment