開始使用免費開始

插入與更新資料表

在操作資料表時,一項非常重要的工作是將值插入資料庫,以及更新既有的值。以下示範兩種操作的語法。

value1value2 插入到 Employee 資料表:

INSERT INTO Employee 
VALUES (value1, value2);

將資料表 Employeefield1 更新為 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;
編輯並執行程式碼