Saturday, 7 June 2014

Oracle Dual Table

I'm very new to oracle, so as of now no knowledge, but learning as I've to survive in IT industry :P. NO other my dear friends. During my learning I met with a term "Dual Table". So whatever I learned
going to share with you. Hope will help a pro who is new to this field just like me :) 

Oracle Dual Table is a table which is created with the data dictionary. Consists exactly one column whose name is dummy and one record. The value of that record is X.

Run following  query on Oracle SQLDeveloper
desc dual, You will this result
Name                    Null?    Type
----------------------- -------- ----------------
DUMMY                            VARCHAR2(1)

Now hit select query on this dual table.
select * from dual; Result as

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. Therefor, dual is the prefered table to select a pseudo column (such as sysdate
select sysdate from dual
Although it is possible to delete the one record, or insert additional records, one really should not do that!.

If this article helped you, don't forget to share it with others.
Thanks.
Reactions:

0 comments:

Post a Comment