通过sql 向数据库插入多行语句

我们知道通过insert into 表名(列名) values(值)是向表中插入一条语句,可是当我们需要向数据库插入多条语句时,应该怎么做呢?

可以通过如下格式的sql 语句来实现一次向数据库插入多行语句:

insert into 表名(列名)

select 值1

union all

select 值2

union all

select 值3

例如:

insert into int_browermark (id,mark)
select 1,'test7' union all
select 1,'test8' union all
select 1,'test9'

执行后,提示3行受影响:

猜你喜欢

转载自www.cnblogs.com/benpao1314/p/9474941.html