Oracle SQL - Understanding How Double Table Works

In the process of creating a small test table, I came across the following article on the Internet: ( http://www.techonthenet.com/sql/insert.php ), which gives the following solution on how to insert multiple rows of fixed values ​​in Oracle:

Insert All
Into testTable (key, field1, field2) Values (1, 10, 'a')
Into testTable (key, field1, field2) Values (2, 20, 'b')
Into testTable (key, field1, field2) Values (3, 30, 'c')
Into testTable (key, field1, field2) Values (4, 40, 'd')
Select * from dual;

Using a double was something that I had not seen before, and so I started to do a little research to understand how this works. I understand that this table is a workaround for a specific oracle syntax, but how it performs theses tasks still don't click on me. I know others have asked a similar question ( How does Oracle SELECT FROM dual work with multiple fields ), but I have not yet seen anyone explain what is actually happening under the hood.

  • Is this a reference trick that they can perform using one valuable table, or are some functions in Oracle simply hardcoded to act differently when they see a double table?

  • More specifically, as a reference to it, the above code allows essentially to cyclically execute several Into ... Values ​​... instructions

Can anyone explain this to me?

+4
source share
1 answer

Functionally dual- it's just a table with one row, in which you can count on always existing and always have exactly one row. You can just as easily create your own single-row table and use it instead dual. Or you can use a query that, as you know, will always return 1 row (i.e. select * from all_objects where rownum < 2).

Oracle dual , . , 1 , . Oracle , " " , - -. , , , - dual .

select * from dual , multi-table INSERT . , INSERT, . , , , SELECT, , .

+6

All Articles