Oracle Foundation of Dual

Source: Internet
Author: User

Excerpt from: http://www.linuxidc.com/Linux/2012-07/66288.htm

1th
Dual is not an abbreviation but a complete word. Dual noun means logarithm, when doing adjectives refers to two heavy, two yuan.

2nd
The dual table in Oracle is a single-row, single-column virtual table.

3rd
The dual table is a table that Oracle automatically creates with the data dictionary, which has only 1 columns dummy, the data type is VERCHAR2 (1), and the dual table has only one data ' X ', and Oracle has an internal logic guarantee that there is always only one data in the dual table.

4th
The dual table is primarily used to select system variables or to find the value of an expression.

5th
A simple example of the most common select Sysdate from daul
Oracle's Select syntax is limited to select * | [Column1 [as ALIAS1], column2 [as ALIAS2]] From table
So without a table name there is no way to query, and the time date is not stored in any table, so the concept of this dual virtual table is introduced.

Use of the dual table

Dual is an actual table in Oracle that can be read by any user, often in a SELECT statement block without a target table.

View current Connected Users
Select User from Dual;
SYSTEM

View current date, time
Select Sysdate from dual;
2012-1-24 on 1

Date conversion
Select To_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual;
2012-01-24 15:02:47

Use as a calculator
Select 1+2 from dual;
3

CREATE VIEW sequence values
Create sequence AAA increment by 1 start with 1;
Select Aaa.nextval from dual;
1

Select Aaa.currval from dual;
1

Dual is a row-by-column table, and if you perform insert,delete,truncate operations inside, it can cause many programs to go wrong. The results are also different for tools such as sql*plus, PL/SQL Dev, and so on. False we insert want to dual insert a piece of data, what will be the result?

INSERT into dual values (' Y ');


SELECT * from dual;
DUMMY
-----
X
Y


Select Sysdate from dual;
Sysdate
-----------
2012-07-15
2012-07-15

This is the time to return two records, which can cause problems. Oracle throws a Too_many_rows (ORA-01422) exception in a stored procedure that obtains time or other information by using the Select Sysdate into V_sysdate from dual.

Therefore, it is very dangerous for the system to ensure that there is only one record in the dual table and that the Update,insert,delete permission of the dual table cannot be freely released.

If you accidentally remove the dual, it can be restored.


Oracle Foundation of Dual

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.