Oracle Temp Table

Source: Internet
Author: User

In addition to saving permanent tables, the Oracle database can also establish temporary table temporary tables. These temporary tables are used to hold data for session sessions, or to store data in a transaction. When the session exits or the user submits a commit and rolls back the rollback transaction, the data for the temporary table is automatically emptied, but the structure of the temporary table and the metadata are also stored in the user's data dictionary.

1. Session-Level staging table
A session-level temporary table is the data in a staging table that exists only during the session life cycle, and when the session ends, Oracle automatically clears the data from the staging table. So here is a common knowledge point, that is, the data of the respective session can only be seen by themselves, different sessions to see the data of their own (different data), this knowledge point in the optimization scenario using a lot.

Format:

Create Global Temporary Table table_name
(xxx int) On Commit Preserve Rows;

2. Transaction-level staging table
A transaction-level temporary table refers to the data in a staging table that exists only during the transaction life cycle.

Create Global Temporary Table table_name
(xxx int)
On Commit Delete Rows;

When a transaction ends (commit or rollback), Oracle automatically clears the data from the staging table. Data for the same transaction-level staging table is also independent between sessions

The most common scenarios for business optimization are as follows:

1 Users bulk scour data storage at a specific time
2 database background through a transit table (XXX) first to the user data landing
3 According to various logic, the XXX table data insert into various business tables

Question 1: A lot of developers put XXX into a regular table, and the developer idea that this is actually just a transit temporary table, the design of the index naturally many people also ignored.

Question 2: This XXX through the multi-user brush data comes in, the amount of data involved should be very large, if designed as a normal table, it is certainly appropriate to some of the processed data to delete, which significantly affect business efficiency.

The performance of this business can be boosted by the nature of the temporal table.

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.