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 etc. SQL allows

Materialized View uses and Benefits in Database #DOTC_Mdb

Materialized View uses and Benefits in Database. Hello Everyone, Today we will discuss about Materialized view as it’s play important role in database. We already discussed about Simple Views and complex views in my previous blog. Before Materialized view go through my previous blog which related to simple view. https://dheeraj60.blogspot.com/2020/05/benefits-of-creating-and-using-view-in.html As we know View is not a database object and not like table which is stored in database, but view can be created from base table a view is an SQL statement that’s stored in the database. This statement, or view, has a name.A view looks and acts a lot like a table. It has columns and rows, and can be included in SELECT queries just like a table. In other word we can say View is a virtual/logical table which is basically used for security purpose. Let’s understand   about   Materialized view : A materialized view is a view that stores the results of the view’s query. Whenever you query the ma

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 some common columns or conditions and also by using alias to fulfill the condition.   There are various types of Joins as li