我有一个类似于以下内容的插入语句:
insert into table (id, name, descr) values (4, 'asdf', 'this is not a word');
我需要使用多个ID插入同一条语句。现在我有:
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');
我只是必须运行此程序,还是有一个更精简的版本?
使用select . . . insert:
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;