sql插入 insert

INSERT INTO 语句用于向表格中插入新的行。

语法:

INSERT INTO 表名称 VALUES (值1, 值2,....)

也可以指定所要插入数据列:

INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)

如:Person表

LastName FirstName Address City
Carter Thomas Changan Street Beijing

(1)添加一行:

INSERT INTO Persons VALUES ('Gates', 'Bill', 'Xuanwumen 10', 'Beijing')

结果为:

LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
(2)添加指定列:

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插入 insert)