INSERT INTO 語句
INSERT INTO 語句用於向表格中插入新的行。
語法
INSERT INTO 表名稱 VALUES (值1, 值2,....)
我們也可以指定所要插入數據的列:
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)
插入新的行
"Persons" 表:
LastName |
FirstName |
Address |
City |
Carter
Thomas
Changan Street
Beijing
SQL 語句:
INSERT INTO Persons VALUES ('Gates', 'Bill', 'Xuanwumen 10', 'Beijing')
結果:
LastName |
FirstName |
Address |
City |
Carter
Thomas
Changan Street
Beijing
Gates
Bill
Xuanwumen 10
Beijing
在指定的列中插入數據
"Persons" 表:
LastName |
FirstName |
Address |
City |
Carter
Thomas
Changan Street
Beijing
Gates
Bill
Xuanwumen 10
Beijing
SQL 語句:
INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
結果:
LastName |
FirstName |
Address |
City |
Carter
Thomas
Changan Street
Beijing
Gates
Bill
Xuanwumen 10
Beijing
Wilson
Champs-Elysees