In the discussion about multiple row insert into the Oracle two approaches were demonstrated:
First:
insert into pager (PAG_ID,PAG_PARENT,PAG_NAME,PAG_ACTIVE)
select 8000,0,'Multi 8000',1 from dual
union all select 8001,0,'Multi 8001',1 from dual
Second:
INSERT ALL
INTO t (col1, col2, col3) VALUES ('val1_1', 'val1_2', 'val1_3')
INTO t (col1, col2, col3) VALUES ('val2_1', 'val2_2', 'val2_3')
INTO t (col1, col2, col3) VALUES ('val3_1', 'val3_2', 'val3_3')
.
.
.
SELECT 1 FROM DUAL;
Could anyone argue the preference of using one over another?
P.S. I didn't do any research myself (even explanation plan), so any information or opinion would be appreciated.
Thanks.
SOME_SEQUENCE.NEXTVAL
as value, gives an Oracle error ORA-02287: sequence number not allowed here (Oracle 11g). A workaround is described here: orafaq.com/forum/t/54217/2 - tryINSERT INTO ... SELECT SOME_SEQUENCE.NEXTVAL, T.* FROM (SELECT ... UNION ALL SELECT ...) T
– Theca