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 |