通过一个查询插入多行

kir*_*ula 2 sql oracle sql-insert

我可以通过以下查询插入两行。如何在其中插入更多行?

insert into friend_name(
     friend_id, 
     first_name, 
     middle_name, 
     last_name)
select  
     3,
     'rich',
     'mond',
     'hill' 
from dual
union all
select 
     4,
     'monunica',
     'bellu',
     'cia' 
from dual
Run Code Online (Sandbox Code Playgroud)

XIN*_*ING 5

您也可以尝试以下方法:

insert all
    into demo_table values (1, 'One', 'X' )
    into demo_table values (2, 'Two', 'Y' )
    into demo_table values (3, 'Three', 'Z' )
select * from dual;
Run Code Online (Sandbox Code Playgroud)

@kiranavula ..如果您只需要在表的几列中插入记录,然后使用以下方法:

将记录仅插入到表的1列。

insert all
    into demo_table(a) values ('One')
    into demo_table(a) values ('Two')
    into demo_table(a) values ('Three')
select * from dual;
Run Code Online (Sandbox Code Playgroud)

  • 哇。我从未见过“全部插入”那样使用-整洁! (2认同)