当前位置: 首页 > 网络学院 > 服务端脚本教程 > SQL > SQL Update
The UPDATE statement is used to modify the data in a table.
UPDATE 声明可用来更新数据表中的数据
UPDATE table_name |
Person:
LastName | FirstName | Address | City |
---|---|---|---|
Nilsen | Fred | Kirkegt 56 | Stavanger |
Rasmussen | Storgt 67 |
We want to add a first name to the person with a last name of "Rasmussen":
我们将给person表中LastName为"Rasmussen"的数据添加一个first name值
UPDATE Person SET FirstName = 'Nina' |
结果:
LastName | FirstName | Address | City |
---|---|---|---|
Nilsen | Fred | Kirkegt 56 | Stavanger |
Rasmussen | Nina | Storgt 67 |
We want to change the address and add the name of the city:
我们将个人信息中Lastname为"Rasmussen"的所在城市名和地址做一次改变:
UPDATE Person |
结果:
LastName | FirstName | Address | City |
---|---|---|---|
Nilsen | Fred | Kirkegt 56 | Stavanger |
Rasmussen | Nina | Stien 12 | Stavanger |