DUAL table in Oracle

DUAL table is a special single row table present by default in Oracle Databases.

Structure of DUAL table
DUAL table has only one column called DUMMY as Varchar2(1) data type and value as X.

1) select 1 from DUAL;
    returns 1

2) select 1+2 from DUAL;
    returns 3

3) select sysdate from DUAL;
    returns system date of oracle database.

4) select `sql` from DUAL;

5) select user from DUAL;
    returns oracle user logged in.

6) select 
   (select empno from emp where empno = 10)
   from DUAL;
    returns 10

DUAL table can be used to test the SQL functions ( Both in-built and user defined functions)

7) select func_salary(10) from DUAL;
where func_salary is a user defined function returns a value when argument is 10.

8) select LOWER(`ORAclE`) from DUAL;
 returns`oracle` where LOWER is a in-built SQL function.

 DUAL table can be used in SQL and PL/SQL.

No comments:

Post a Comment