多次插入相同的数据 [英] Insert same data multiple times

查看:64
本文介绍了多次插入相同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于以下内容的插入语句:

I have an insert statement similar to this:

insert into table (id, name, descr) values (4, 'asdf', 'this is not a word');

我需要插入具有多个ID的同一条语句.现在我有:

I need to insert this same statement with multiple ids. Right now I have:

insert into table (id, name, descr) values (4, 'asdf', 'this is not a word');
insert into table (id, name, descr) values (6, 'asdf', 'this is not a word');
insert into table (id, name, descr) values (7, 'asdf', 'this is not a word');
insert into table (id, name, descr) values (9, 'asdf', 'this is not a word');

我只是必须运行此程序,还是有一个更精简的版本?

Am I just going to have to run this, or is there a more condensed version?

推荐答案

使用select . . . insert:

insert into table(id, name, descr) 
    select i.id, 'asdf', 'this is not a word'
    from (select 4 as id from dual union all
          select 6 from dual union all
          select 7 from dual union all
          select 9 from dual
         ) i;

这篇关于多次插入相同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆