Oracle Temp Table

Source: Internet
Author: User
In some cases, it takes several very large tables to correlate the case,  but the time to retrieve is a small amount of data.
You can first retrieve the large table data, then insert it into the temporary table, and then associate the processing.
For example:
A database of a department store.
It has the following 2 tables without partitions.
Sales table: Sales date, sales serial number, sales amount
Sales schedule: Sales serial number, sales items, sales quantity

When the above table contains data for several years later.
If you want to query yesterday's sales totals. Very simple
SELECT * FROM sales table WHERE Sales date = yesterday.

But when you want to inquire about yesterday's sale, the sale of some kind of goods time. Is




On (Sales table. Sales Serial Number =
WHERE
Sales table. Sales date = yesterday
and sales schedules. Sales Items = an item

In this case, the query time is very long due to the 2 large table associations.

Temporary tables can be passed.
First

SELECT * FROM sales table WHERE Sales date = yesterday

and then
INSERT into temp table 2
SELECT * FROM sales list WHERE sales serial number in (SELECT sales serial number from temporary table 1)

At last

......


On (temporary table 1. Sales Serial number =

This is 2 small table correlation processing, query up, faster.

Oracle Temp Table

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.