Thursday, June 25, 2009

Duel with Dual

Dual is a default table that comes with all Oracle db installations. It is tiny table with just one column and has just one row. See desc below.

desc dual;
DUMMY

select * from dual;
DUMMY
X

It's owner is SYS but all users have access to it. This table always returns one row. So that's something that comes in handy.

Usages:
1. mostly to select pseudo columns from tables or views
2. test any of the Oracle functions

e.g.
select to_date(sysdate) as system_date from dual;
SYSTEM_DATE
6/25/2009

select 'ruchi' as name, 'crazy' as fame from dual;
NAME FAME
ruchi crazy

select upper('ruchi') as ucase from dual;
UCASE
RUCHI

No comments:

Post a Comment