Saturday 7 October 2017

Use Of DUAL Table

  • This is a single row and single column(called DUMMY as Varchar2(1) data type and value as X) dummy table provided by oracle. 
  • This is used to perform mathematical calculations.
  • Select statement can only retrieve data from data base object (like table etc), some time we need to fetch the data which never saved in data base objects like SYSDATE (oracle will fetch SYSDATE from bios)  for that we need to use DUAL table.


Examples:
SQL> select 100 from DUAL;
returns 100

SQL> select 100+2 from DUAL;
returns 102

SQL> select sysdate from DUAL;
returns system date and time.

SQL> select 'string' from DUAL;
returns 'string'

SQL>select user from DUAL;
returns oracle user logged in.

To call the SQL functions ( Both in-built and user defined functions) we use DUAL table.

SQL>select user_define_function(parameter) from DUAL;
call user define function using dual

SQL>select LOWER('STRING') from DUAL;
returns 'string' where LOWER is a in-built SQL function.






No comments:

Post a Comment