Temporary table, oracle temporary table

Source: Internet
Author: User

Temporary table, oracle temporary table
Temporary tables allow users to operate only their own data without interfering with each other, so they do not have to worry about damaging or affecting data of other sessions/transactions. Temporary tables can be divided into SESSION and TRANSACTION. 1. SESSION-level temporary table data exists throughout the SESSION until the SESSION is terminated; 2. the temporary table data at the TRANSACTION level disappears after the TRANACTION ends. That is, the temporary table data in the COMMIT/ROLLBACK or end SESSION is cleared. Syntax of the two temporary tables: create global temporary table name on commit preserve | when delete rows uses preserve, It is a SESSION-level temporary table, delete is a temporary table at the TRANSACTION level. 1. A temporary table at the SESSION level is created. create global temporary table temp_tbl (col_a varchar2 (30 )) on commit preserve rows 2. insert data into temp_tbl values ('test session table') 3. Submit commit; 4. query the data select * from temp_tbl. You can see that the data 'test session table' record is still in progress. End the SESSION, log on again, and query the data select * from temp_tbl. At this time, the record does not exist, because the system automatically clears records at the end of the session ii. TRANSACTION-level temporary table 1. creates a temporary table create global temporary table temp_tbl (col_a varchar2 (30) on commit delete rows; 2. insert into temp_tbl values ('test transaction table') into data; 3. Submit commit; 4. query data select * from temp_tbl; at this time, we can see that the inserted record 'test transaction table' does not exist. Similarly, if the SESSION is terminated without submission, the logon record does not exist.

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.