Saturday, May 7, 2016

What is the dual table?

In oracle, it's not possible to type a select statement without the from clause. So oracle came up with the "dual" table which is an actual table.

For instance getting the system date with the function "sysdate" will fail as follow:
SQL> select sysdate;
select sysdate
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

Typing desc dual will show the following:
SQL> desc dual;
Name         Null?    Type
----------- -------- --------------------
DUMMY                 VARCHAR2(1)

It has precisely one column and one row with a value of 'X':

SQL> col dummy for a5
SQL> select * from dual;


With the dual table as a placeholder, we can obtain our sysdate:

SQL> select sysdate from dual;

No comments :

Post a Comment