插入和更新表
在处理表时,一个非常重要的任务是向数据库插入和更新值。下面给出了这两种操作的语法。
将 value1 和 value2 插入到 Employee 表:
INSERT INTO Employee
VALUES (value1, value2);
将表 Employee 中 field1 的值更新为 value1,条件为 ID=1:
UPDATE Employee
SET field1 = value1
WHERE ID = 1;
您的任务是向 Person 表插入两个新值,并更新该表中的记录。
本练习是课程的一部分
SQL Server 中的分层与递归查询
交互式实操练习
通过完成这段示例代码来试试这个练习。
-- Insert the records for the person with ID=1
___ INTO ___
____ (1,'Andrew','Anderson','Union Ave 10','New York','1986-12-30');
-- Insert the records for the person with ID=2
INSERT INTO Person
VALUES (___,___,___,___,___,___);
SELECT *
FROM Person;