74914

Does MYSQL overwrite a column of same value on update?

Question:

When updating a table in mysql, for example:

<blockquote>

<strong>Table</strong> user

</blockquote> user_id | user_name 1 John 2 Joseph 3 Juan

If I run the query

UPDATE `user` SET user_name = 'John' WHERE user_id = 1

Will MYSQL write the same value again or ignore it since it's the same content?

<hr />

This is a Q&A question I made, as <a href="https://stackoverflow.com/help/self-answer" rel="nofollow">Stack Overflow encourages</a> it, I think it will be helpful in the future for the fellow programmers with the same question.

Answer1:

As the <a href="http://dev.mysql.com/doc/refman/5.7/en/update.html" rel="nofollow">MYSQL Manual for the UPDATE statement</a> implies,

<blockquote>

If you set a column to the value it currently has, MySQL notices this and does not update it.

</blockquote>

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.

Recommend

  • Can't restore packages on macOS Sierra
  • scala.collection.Seq doesn't work on Java
  • Extract string between xml tags in android without parsing the xml
  • Writing dataframe to postgres database
  • C++ std::set comparator
  • Prolog Query - Trying to understand how this result happens
  • How to retrieve a specific string from a specific list from a file with JSON in Python
  • Does the failbit effect the call ignore on cin?
  • Haskell: function composition with anonymous/lambda function
  • How to Add Polymorphic Comments to Feed?
  • Creating a Multidimensional, Associative Array in VBScript
  • User messaging system
  • MYSQ & MVC3 SQL connection error \\ ProviderManifestToken but I am using MySQL
  • Laravel: Getting Session ID oddly truncates when using foreach
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Moving mysql files across servers
  • Highlight one bar in a series in highcharts?
  • Email format validation in mvc3 view
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • How to add date and time under each post in guestbook in google app engine
  • How to check if every primary key value is being referenced as foreign key in another table
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Circular dependency while pushing http interceptor
  • Comma separated Values
  • Linker errors when using intrinsic function via function pointer
  • Load html files in TinyMce
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF