Friday, 9 January 2015

what is dual table in oracle?

In school days we have cam across this query in data base to fetch the date in database.

select sysdate from dual;

What is that dual?

Dual is one dummy table in oracle database. It is created by default while installing the oracle database.

It contains one field and one column.

Field name: DUMMY VARCHAR(1);

It contains the value as x.

To know more just execute the following query.

select * from dual;

The output will be


What is the need for dual table?

when one want to perform some arithemetic operations,selecting the pseudo columns can use the dummy dual table because oracle do not allow to perform arithemetic operations without from clause

I.e you cannnot run "select 5*4" in oracle database. From clause required error will be thrown.

For eg:

select  5*5 from dual;
select  sysdate  from dual;
select sysuser from dual;