MySQL错误代码:MySQL Workbench中UPDATE期间的1175错误代码

本文翻译自:MySQL error code: 1175 during UPDATE in MySQL Workbench

I'm trying to update the column visited to give it the value 1. I use MySQL workbench, and I'm writing the statement in the SQL editor from inside the workbench. 我正在尝试更新visited的列以赋予它值1.我使用MySQL工作台,并且我在工作台内部在SQL编辑器中编写语句。 I'm writing the following command: 我正在编写以下命令:

UPDATE tablename SET columnname=1;

It gives me the following error: 它给了我以下错误:

You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option .... 您正在使用安全更新模式,并且您尝试更新没有使用KEY列的WHERE的表要禁用安全模式,请切换选项....

I followed the instructions, and I unchecked the safe update option from the Edit menu then Preferences then SQL Editor . 我按照说明操作,然后从Edit菜单中取消选中safe update选项,然后取消选择Preferences然后选择SQL Editor The same error still appear & I'm not able to update this value. 仍然出现相同的错误,我无法更新此值。 Please, tell me what is wrong? 拜托,告诉我有什么问题?


#1楼

参考:https://stackoom.com/question/m2AG/MySQL错误代码-MySQL-Workbench中UPDATE期间的-错误代码


#2楼

I found the answer. 我找到了答案。 The problem was that I have to precede the table name with the schema name. 问题是我必须在表名前加上模式名称。 ie, the command should be: 即,命令应该是:

UPDATE schemaname.tablename SET columnname=1;

Thanks all. 谢谢大家。


#3楼

It looks like your MySql session has the safe-updates option set. 看起来您的MySql会话设置了safe-updates选项 This means that you can't update or delete records without specifying a key (ex. primary key ) in the where clause. 这意味着如果不在where子句中指定密钥(例如primary key ),则无法更新或删除记录。

Try: 尝试:

SET SQL_SAFE_UPDATES = 0;

Or you can modify your query to follow the rule (use primary key in where clause ). 或者,您可以修改查询以遵循规则(在where clause使用primary key )。


#4楼

Follow the following steps before executing the UPDATE command: In MySQL Workbench 在执行UPDATE命令之前,请执行以下步骤: 在MySQL Workbench中

  1. Go to Edit --> Preferences 转到Edit - > Preferences
  2. Click "SQL Editor" tab and uncheck "Safe Updates" check box 单击"SQL Editor"选项卡, uncheck “安全更新” check box
  3. Query --> Reconnect to Server // logout and then login Query - > Reconnect to Server //注销然后登录
  4. Now execute your SQL query 现在执行SQL查询

ps, No need to restart the MySQL daemon! ps,无需重启MySQL守护进程!


#5楼

SET SQL_SAFE_UPDATES=0;
UPDATE tablename SET columnname=1;
SET SQL_SAFE_UPDATES=1;

#6楼

SET SQL_SAFE_UPDATES=0;

OR 要么

Go to Edit --> Preferences 转到 Edit --> Preferences

Click SQL Queries tab and uncheck Safe Updates check box 单击“ SQL Queries选项卡,然后取消选中“ Safe Updates复选框

Query --> Reconnect to Server

Now execute your sql query 现在执行你的SQL查询

发布了0 篇原创文章 · 获赞 8 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/asdfgh0077/article/details/105482048