What is the dual table in Oracle?

Source: Internet
Author: User

The following statements are frequently seen in projects:

Select seq_project.nextval from dual

Used to obtain the sequence value. But I didn't create the dual table. who created this table? What is it mainly used?

Some of the explanations I have found are as follows:

Dual is a table automatically created by Oracle and the data dictionary. It has only one column: dummy, whose data type is varchar2 (1 ).

There is only one row of data in dual: 'X '.

Dual belongs to SYS mode, but all users can access it using the dual name. This table is often used to calculate the constant expression and pseudo column equivalence using select, because it only returns one row of data, while multiple data rows may be returned when other tables are used.

 

1. view the current user. You can execute the following statement in SQL plus.
Select User from dual;
2. Used to call system functions
Select to_char (sysdate, 'yyyy-mm-dd hh24: MI: ss') from dual; -- get the current system time
Select sys_context ('userenv', 'terminal') from dual; -- get the host name
Select sys_context ('userenv', 'language') from dual; -- get the current locale
Select dbms_random.random from dual; -- obtain a random number
3. Obtain the next or current value of the sequence. Use the following statement.
Select your_sequence.nextval from dual; -- Obtain the next value of the sequence your_sequence
Select your_sequence.currval from dual; -- get the current value of the sequence your_sequence
4. It can be used as a calculator.
Select 7*9 from dual;

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.