DBA Tips Archive for Oracle
What is the table DUAL used for?
by Jeff Hunter, Sr. Database Administrator
The table SYS.DUAL gets created for you when you create the database. DUAL is in the schema of the user SYS, but is accessible by the name DUAL to all users. It contains only ONE column, DUMMY (defined to be VARCHAR2(1)) and ONE record with a value 'X'. Oracle created this table since it makes some calculations valid and more convenient.
SELECT (2918/23)+130 FROM dual;
SELECT emp_seq.NEXTVAL FROM dual;
SELECT chr(70) FROM dual;
Avoiding problems with the DUAL table
Note that DUAL can have more than one record. The kernel knows that DUAL
is a single row single column table, but the PLSQL engine does not.
This is important because things will break if it contains more than
one. If you are running Oracle Applications, some patches dump multiple
rows into the DUAL table. That is why the ADADMIN utility gives you options
to check the dual table. It is highly recommend to do this.
Copyright (c) 1998-2017 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at firstname.lastname@example.org.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.