Operating System - HP-UX
1753506 Members
5020 Online
108794 Solutions
New Discussion

Re: why does "select 1 from dual" work - what is the "1"?

 
SOLVED
Go to solution
R. Allan Hicks
Trusted Contributor
Solution

Re: why does "select 1 from dual" work - what is the "1"?

The syntax may not make sense on first look, but if you think about it... .

1 is a literal. If you select 1 from emp; as scott/tiger, you'll see a bunch of 1's. It's similar to saying

select 'Employee Name : '||ename from emp; The string is a literal and is echoed for each row. In this case, it allows you to pretty up a report. You need the single quotes so as not to imply that you mean a column name. Since a column name of 1 is not legal, sqlplus gives you a break and assumes that it is a literal.

Hope that this helped

Dual is, as many have pointed out, a convince table, It is handy for things like select sysdate from dual;
"Only he who attempts the absurd is capable of achieving the impossible
abc_18
Regular Advisor

Re: why does "select 1 from dual" work - what is the "1"?

.