Does MySQL overwrite a column of same value on update?(MySQL 是否会在更新时覆盖相同值的列?)
问题描述
在 MySQL 中更新表时,例如:
When updating a table in MySQL, for example:
表格 用户
user_id | user_name
1 John
2 Joseph
3 Juan
如果我运行查询
UPDATE `user` SET user_name = 'John' WHERE user_id = 1
MySQL 会再次写入相同的值还是忽略它,因为它是相同的内容?
Will MySQL write the same value again or ignore it since it's the same content?
推荐答案
作为 MySQL UPDATE 语句手册 暗示,
如果您将列设置为其当前具有的值,MySQL 会注意到这一点并且不更新它.
If you set a column to the value it currently has, MySQL notices this and does not update it.
因此,如果您运行此查询,MySQL 将了解您尝试应用的值与指定列的当前值相同,并且不会向数据库写入任何内容.
So, if you run this query, MySQL will understand that the value you're trying to apply is the same as the current one for the specified column, and it won't write anything to the database.
这篇关于MySQL 是否会在更新时覆盖相同值的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 是否会在更新时覆盖相同值的列?
基础教程推荐
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
