Possible Duplicate:
What is the dual table in Oracle?
I have always wondered how does the query like:
select sysdate
from dual;
or
select 8
from dual;
do work.
As I’m used to select statement selects column/s value from a given table. But in the examples
mentioned above table dual DOESN’T have sysdate or just ‘8’ columns….
Could someone explain me how it works?
You don’t have to select columns. You can select expressions, which can by columns, constant values, function calls, calculations…. So you could select this from an employee table
Note
as nameandas age. This is because the column name is lost once an expression contains more that just a column name. In that case, you can specify the name that you want the column to have in the query results. A similar trick is done for the table name itself. The aliaseis just a shorthand. This is especially useful when using multiple tables (in a join). In this simple query, the table alias can be omitted altogether.dualis just a special table that has 1 row exactly, and one column nameddummy. It has many different uses which have been discussed before. From Oracle 23c onwards,from dualis optional, as it has been in MySQL for a while longer. You can simply write: