SQL 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
|
SQL UPDATE 语句Update 语句
语法:UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
Person:
LastName
|
FirstName
|
Address
|
City
|
Gates
|
Bill
|
Xuanwumen 10
|
Beijing
|
Wilson
|
Champs-Elysees
|
更新某一行中的一个列
UPDATE Person SET FirstName = 'Fred' WHERE LastName = 'Wilson'
结果:
LastName
|
FirstName
|
Address
|
City
|
Gates
|
Bill
|
Xuanwumen 10
|
Beijing
|
Wilson
|
Fred
|
Champs-Elysees
|
更新某一行中的若干列
UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'WHERE LastName = 'Wilson'
结果:
LastName
|
FirstName
|
Address
|
City
|
Gates
|
Bill
|
Xuanwumen 10
|
Beijing
|
Wilson
|
Fred
|
Zhongshan 23
|
Nanjing
|
SQL DELETE 语句
DELETE 语句
语法:DELETE FROM 表名称 WHERE 列名称 = 值
Person:
LastName
|
FirstName
|
Address
|
City
|
Gates
|
Bill
|
Xuanwumen 10
|
Beijing
|
Wilson
|
Fred
|
Zhongshan 23
|
Nanjing
|
删除某行
DELETE FROM Person WHERE LastName = 'Wilson'
结果:
LastName
|
FirstName
|
Address
|
City
|
Gates
|
Bill
|
Xuanwumen 10
|
Beijing
|
删除所有行
DELETE FROM table_name
DELETE * FROM table_name