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)