Friday, July 18, 2008

Concept of DUAL table.

Dual is a table which is created by oracle along with the data dictionary. It consists of exactly one column whose name is dummy and one record. The value of that record is X.

sql> desc dual
Name..... Null..... Type
----------------------- -------- ----------------
DUMMY VARCHAR2(1)

sql> select * from dual;
D
-
X

The owner of dual is SYS but dual can be accessed by every user. As dual contains exactly one row (unless someone fiddled with it), it is guaranteed to return exactly one row in select statements if a constant expression selected against dual, such as in:

select sysdate from dual ;

Although it is possible to delete the one record, or insert additional records, but one really should not do that!.