Skip to main content

Dual Table in Oracle and its uses in Database #Diksha Oracle Training Centre

 

Dual Table in Oracle and its uses in Database.

Hello Everyone,

Today we will discuss about Dual table in Oracle and it’s benefit in Database.Dual table in Oracle which is a special and dynamic table used for evaluating expressions or calling functions. Once you Install Oracle Database in your System Dual table is available in all schema’s . The DUAL table contains one column named DUMMY whose data type is VARCHAR2() and contains one row with a value X. The DUAL table is most simple one because it was designed for fast access and can be used for any calculation checking date and printing any value as the output for our requirement. To Access Dual table we can use Select statement.

To see the output from Dual table we can use below select statement and can see output as column DUMMY with one Row value X.

Select * 

from dual;

By using the DUAL table, we can execute queries that contain functions that do not involve any table like the UPPER() function as below:

SELECT

  UPPER('Welcome to Diksha Oracle Training Centre')

FROM

  dual;

Output of above query in Oracle compiler is as below.

 




From dual table we can  can use expressions in the SELECT clause of a query that accesses the DUAL table. Below are the select statement for calculation of any number from the dual table.

 

Select

( 20+30/2)

Calculation

From Dual;

 

Output of above query in Oracle compiler is as below.



From Dual table we can check the current date with date format for Oracle and also we can manipulate date format as per our requirement.

Seeing the current date and it’s format we can use below query.

Select

Sysdate

From dual;

Changing date format from default we can use below query :

Note : Date format we can change as per our requirement in different format such  as 'DD-MON-YY', 'DD-MM-YY', 'YYYY-MM-DD'  etc as per our need.

select

TO_CHAR(sysdate ,'DD-MON-YY')

from

dual;

Output of above query is as below :



 


Below SQL code display the numbers 1 to 8 from DUAL.

 

SELECT level

FROM DUAL

CONNECT BY level <=8;

 

Output of above Query is as below in Oracle Compiler.



 

Note :Owner of DUAL table is SYS which owns the data dictionary, therefore DUAL is part of the data dictionary so DUAL Table can be accessed by every user exist in the Oracle database. Please explore Dual table as much as you can for calculation and other activities as per your requirement.

Oracle treats the use of DUAL the same as calling a function which simply evaluates the expression used in the select list. Optimization provides even better performance than directly accessing the physical DUAL table. Dual table plays very important role in Oracle database as this table can be used for multipurpose for data calculation and other activities in SQL as well as PL/SQL block.

 

Please go through this blog carefully and let me know if you have any questions as dual table in Oracle is very important and this blog is important for fresher candidate who is preparing for interview as an Oracle SQL and PL/SQL developer as some questions asked from this topic as well during interview.

Thanks.



Comments

Post a Comment

Popular posts from this blog

SQL and Classification of SQL in Oracle Database #Diksha Oracle Training Centre

  SQL and Classification of SQL in Oracle Database.   SQL is Structured Query Language , which is used for storing, manipulating and retrieving data stored in a relational database .SQL is the standard language for RDBMS. All the Relational Database Management Systems (RDMS) like Oracle, MySQL, Sybase, Informix, IBM DB2 and Microsoft SQL Server use SQL as their standard database language. Oracle is one of the more secured database as compared to other databases. Importance of   SQL : SQL and PL/SQL is a backend process where all data is stored and retrieved in GUI which created either by any programming languages like Java, C++, PHP etc. so we need to have very secure database so that there will be no impact for users. SQL allows users to access data in the relational database management systems. SQL is used to communicate with a database.SQL and PL/SQL allows users to create and drop databases tables , views , stored procedures , functions , packages , trigger et...

Top 50 Interview Questions On SQL and PL/SQL #DOTC_Mdb

                    Top 50 Interview Questions On SQL and PL/SQL. Today we will Discuss Top 50 interview questions and answers of SQL and PL/SQL which is frequently asked in interview.     Question 1: What is SQL and Classification of SQL? Answer SQL is a Structure Query Language which is vastly used in RDBMS database like Oracle, Sybase, DB2 , Microsoft SQL server etc.   Classification of SQL is as below: DDL (Data Definition Language):  Commands are  create , alter , drop , truncate etc DML (Data Manipulation Language) : Commands are  insert,update and delete . TCL (Transaction Control Language ) : Commands are  Commit , Rollback and Save point. DCL (Data Control Language) : Commands are Grant , Revoke Question 2:    What is meant by Joins? What are the types of join? Answer Joins are basically used to extract/get data from multiple tables using s...

Aggregate Functions and Group By Clause in Oracle with Examples #Diksha Oracle Training Centre

  Aggregate Functions and Group By Clause Oracle with Examples.   Hello Everyone, Today I will   discuss about   Aggregate function in SQL by using Group By Clause and different clauses with some examples . Please go tjrough my previous blogs in Archive folder for classification of SQL, Commands and   SQL joins for your understanding.   Aggregate Functions Allows us to perform a calculation on a set of values to return a single value . We can use Group by Clause to group the result-set by one or more columns. Also we can use Having clause to restrict or filter the data as per our requirement. Note: Whenever we use Aggregate function in SQL we can’t able to use where condition. To restrict or filter the record we need to use having clause instead of Where. Below is the most commonly used Aggregate function in SQL.   MAX : Max function   used to get the maximum values in a set of values. COUNT : This function used to count rows in ...