Data Management for database series (update data)

Source: Internet
Author: User

Grammar


Update < table name > set < Column name = value > [WHERE < update condition;]

Attention:
(1) < column name = value > is required to update a column of data in a table, multiple occurrences can occur after set, separated by commas.
(2) The WHERE keyword is optional and is used to qualify the condition and all rows of data in the table will be updated if the UPDATE statement is not qualified.

Example One


Change the city of residence of all authors in the author's table to "Beijing"

UPDATE SET City=' Beijing '

Example Two


An expression can also be used in an UPDATE statement

UPDATESET Price=Price-2WHERE Catagoryid=  1OR Catagoryid=2

Question 1
You can update the primary key column data, but you should ensure that the updated primary key column data cannot have duplicate information, or the update fails!

Question 2
You can update the table foreign key column data, but you should ensure that the new data should exist in the primary key table beforehand

Data Management for database series (update data)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.