DUAL Table in Oracle

Defining Dual Table :

  • DUAL is a Special table having one row and one column.
  • The Datatype of the Column is Varchar2(1) , Column Name is ‘DUMMY’ and Value is ‘X’.
  • It is created automatically by Oracle along with Data dictionary.
  • It is owned by SYS User , but accessible to all users.

Use of Dual Table in oracle:

Besides the data which is stored in the Database , SELECT Statement can also be used for the data which is not stored in the database e.g. to perform some calculation , fetch sysdate etc. Let’s understand this with an example as given below.

Example of performing some calculation:

Suppose, we want to perform an operation of adding two numbers i.e. 10 and 20 which does not exist in the database.Oracle do not have any placeholder to perform calculations internally, and there is no command in Oracle like  (SELECT 10 +20 ;). This is where DUAL Table is used to run such SQL statements that do not have any logical table name.Thus, Dual Table is used to get Data from such pseudo columns .

The above Query can then be written as SELECT 10 + 20 FROM DUAL;

Reason of Single Column in Dual Table:

 

Questions/Suggestions
Have any question or suggestion for us?Please feel free to post in Q&A Forum

Shikha Katariya

Shikha

You may also like...

1 Response

  1. August 12, 2015

    […] Dual Table […]