The role of the dual table for Oracle databases

Source: Internet
Author: User

Dual is the smallest worksheet provided by Oracle, with a single row and some special functions.

Regardless of what you do (don't delete records), it has only one record-' X '.

Role:

1. Select evaluates constant expression and pseudo-column equivalence. The dual table can only return one piece of data, and multiple data may be returned when using a different table.

2. View Current User

Select User from Dual;

Select COUNT (*) from dual;

3. As a calculator

Select 7*9*10-10 from Fual;

4. Call system functions

Get current system time

Select To_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual;

Get host Name

Select Sys_context (' Userenv ', ' terminal ') from dual;

Get current locale

Select Sys_context (' Userenv ', ' language ') from dual;

Get a random number

Select Dbms_random.random from dual;

5. View sequence values

Create sequence AAA starting at 1, plus 1 per time

Create sequence AAA increment by 1 start with 1;

Gets the next sequence value of the sequence AAA

Select Aaa.nextval from dual;

Gets the current sequence value of the sequence AAA

Select Aaa.currval from dual;

The role of the dual table for Oracle databases

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.