what is the difference with both query ? are they same ? do they give the same results ? I saw them in a script and I wonder if there is a difference.
Query 1 :
insert into tab1 ( id , name , last ) values ( 1 , 'st' , 'ov');
Query 2 :
insert into tab1 ( id , name , last ) select 1 , 'st' , 'ov' from dual;
There is no difference in this case.
Using a select ... from dual
for the insert can be useful in some cases (when using data from another table for example, an union
, etc.), but in this case it doesn't add anything to the usual insert into
.
Consider this being useful:
insert
into table_x
( col1
)
select 'a'
from dual
union
all
select 'b'
from dual
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.