sql语句怎么多行插入?

来源:百度知道 编辑:UC知道 时间:2024/06/30 04:50:21
insert into departments (department_id,department_name,location_id)values (290,'abad',1709) insert into departments (department_id,department_name,location_id)values (300,'TTT',1700)非要写2遍么? 怎么把我要插入了2条数据(290,'abad',1709) 和(300,'TTT',1700)在一条语句中写完? 如果我要插10条 insert要写10遍?有简写方法么?

insert into departments (department_id,department_name,location_id)values (290,'abad',1709)
go
insert into departments (department_id,department_name,location_id)values (300,'TTT',1700)
go
只能这样可以同时插入2条 insert 语句又不要你自己写,每个数据库都有自动生成脚本功能的。

insert into departments(department_id,department_name,location_id)select 290,'abad',1709
union
select 300,'TTT',1700;

/*一条sql*/

insert into departments (department_id,department_name,location_id)values (290,'abad',1709)(300,'TTT',1700)

中间用and连接不可以吗?