Why should we do SELECT after "INSERT ALL"?

As I saw on many sites, if I want to do INSERT ALL , I have to finish it with SELECT (Like SELECT * FROM dual;)

Why?

+4
source share
2 answers

A subquery is required for the INSERT ALL syntax (see http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#i2111652 )

an insert clause is executed for each row returned by a subquery (i.e., a SELECT statement). SELECT * FROM dual returns one row, so insert_clause (s) is executed once (which is useful when you want to insert a hard set of values)

+5
source

As shown in the documentation , the INSERT ALL syntax expects a subquery: you cannot have INSERT ALL [...] VALUES [...] .

I suspect that SELECT from dual is a way to make multiple tabs of the same row on multiple tables.

0
source

Source: https://habr.com/ru/post/1314414/


All Articles