tags:

views:

3402

answers:

9

I heard people reffering to this table and was not sure what is was about.

+6  A: 

I think this wikipedia article may help clarify.

http://en.wikipedia.org/wiki/DUAL_table

The DUAL table is a special one-row table present by default in all Oracle database installations. It is suitable for use in selecting a pseudocolumn such as SYSDATE or USER The table has a single VARCHAR2(1) column called DUMMY that has a value of "X"

smink
A: 

Kind of a pseudo table you can run commands against and get back results, such as sysdate. Also helps you to check if Oracle is up and check sql syntax, etc.

+11  A: 

It's a sort of dummy table with a single record used for selecting when you're not actually interested in the data, but instead want the results of some system function in a select statement:

e.g. select sysdate from dual

See http://www.adp-gmbh.ch/ora/misc/dual.html

Sean McMains
A: 

it's the special table in Oracle. I often use it for calculation or checking system variable. For example;

  • "Select 2*4 from dual" prints out the result of the calculation
  • "Select sysdate from dual" prints the server current date.
Martin
A: 

It is a dummy table with one element in it. It is useful because Oracle doesn't allow statements like

SELECT 3+4

You can work around this restriction by writing

SELECT 3+4 FROM DUAL

instead.

mfx
A: 

It's a object to put in the from that return 1 empty row. For example: select 1 from dual; returns 1

select 21+44 from dual; returns 65

select [sequence].nextval from dual; returns the next value from the sequence.

A: 

The DUAL table is a special one-row table present by default in all Oracle database installations. It is suitable for use in selecting a pseudocolumn such as SYSDATE or USER

The table has a single VARCHAR2(1) column called DUMMY that has a value of "X"

You can read all about it in http://en.wikipedia.org/wiki/DUAL_table

Sakin
+4  A: 

From Wikipedia

History

The DUAL table was created by Chuck Weiss of Oracle corporation to provide a table for joining in internal views:

I created the DUAL table as an underlying object in the Oracle Data Dictionary. It was never meant to be seen itself, but instead used inside a view that was expected to be queried. The idea was that you could do a JOIN to the DUAL table and create two rows in the result for every one row in your table. Then, by using GROUP BY, the resulting join could be summarized to show the amount of storage for the DATA extent and for the INDEX extent(s). The name, DUAL, seemed apt for the process of creating a pair of rows from just one. [1]

It may not be obvious from the above, but the original DUAL table had two rows in it (hence its name). Nowadays it only has one row.

Optimization

DUAL was originally a table and the database engine would perform disk IO on the table when selecting from DUAL. This disk IO was usually logical IO (not involving physical disk access) as the disk blocks were usually already cached in memory. This resulted in a large amount of logical IO against the DUAL table.

Later versions of the Oracle database have been optimized and the database no longer performs physical or logical IO on the DUAL table even though the DUAL table still actually exists.

bosnic
A: 

DUAL is necessary in PL/SQL development for using functions that are only available in SQL

e.g.

DECLARE
x XMLTYPE;
BEGIN
SELECT xmlelement("hhh", 'stuff')
INTO x
FROM dual;
END;
steevc