Oracle while usage sample sharing _oracle

Source: Internet
Author: User

When a section is used more than once in a query, a public temporary table can be created with an Oracle with statement. Because the subquery avoids repeated parsing in the memory temp table, the execution efficiency improves a lot. Temporary tables are automatically cleared at the end of a query.

General syntax Format:

Copy Code code as follows:

With
Alias_name1 as (Subquery1),
Alias_name2 as (SubQuery2),
... alias_namen as (Subqueryn)
Select Col1,col2 ... col3
From Alias_name1,alias_name2......,alias_namen

Examples of Oracle with statements:

Copy Code code as follows:

With Q1 as (SELECT 3 + 5 S from DUAL),
Q2 AS (SELECT 3 * 5 M from DUAL),
Q3 as (SELECT S, M, S + M, S * m from Q1, Q2)
SELECT * from Q3;

Output results:

Copy Code code as follows:

1 8 15 23 120

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.