Sunday, 2 September 2007

The Dual Table

Dual Table is a table that contais a single row.
The dual table has one VARCHAR2 column named dummy.
Dual contains a single row with the value X.

Oracle has created this since it makes some calculations more convenient.

SQL> describe dual;
Name Type Nullable Default Comments
----- ----------- -------- ------- --------
DUMMY VARCHAR2(1) Y

SQL> select * from dual;

DUMMY
-----
X

You can use it for math :

SQL> Select (202*44)/4 from dual;

(202*44)/4
----------
2222

You can use it to increment sequences :

SQL> select seq_no_tx.nextval from dual;

NEXTVAL
----------
1402