我有一个类似于这的插入语句:
insert into table (id, name, descr) values (4, 'asdf', 'this is not a word');
Run Code Online (Sandbox Code Playgroud)
我需要插入带有多个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');
Run Code Online (Sandbox Code Playgroud)
我只是要运行它,还是有更浓缩的版本?
使用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;
Run Code Online (Sandbox Code Playgroud)