?
Update
用途:
?????? 更新表中原有数据
语法:
UPDATE table_name SET column_name = new_value WHERE column_name = some_value
例:
“Person”表中的原始数据:
LastName
FirstName
Address
City
Nilsen
Fred
Kirkegt 56
Stavanger
Rasmussen
?
Storgt 67
?
运行下面的SQL将Person表中LastName字段为”Rasmussen”的FirstName更新为”Nina”:
UPDATE Person SET FirstName = 'Nina' WHERE LastName = 'Rasmussen'
更新后”Person”表中的数据为:
LastName
FirstName
Address
City
Nilsen
Fred
Kirkegt 56
Stavanger
Rasmussen
Nina
Storgt 67
?
同样的,用UPDATE语句也可以同时更新多个字段:
UPDATE Person SET Address = 'Stien 12', City = 'Stavanger' WHERE LastName = 'Rasmussen'
更新后”Person”表中的数据为:
LastName
FirstName
Address
City
Nilsen
Fred
Kirkegt 56
Stavanger
Rasmussen
Nina
Stien 12
Stavanger
Delete
用途:
?????? 删除表中的数据
语法:
DELETE FROM table_name WHERE column_name = some_value
例:
“Person”表中的原始数据:
LastName
FirstName
Address
City
Nilsen
Fred
Kirkegt 56
Stavanger
Rasmussen
Nina
Stien 12
Stavanger
删除Person表中LastName为”Rasmussen”的数据:
DELETE FROM Person WHERE LastName = 'Rasmussen'
执行删除语句后”Person”表中的数据为:
LastName
FirstName
Address
City
Nilsen
Fred
Kirkegt 56
Stavanger
?