Create a temporary table in Oracle.

Source: Internet
Author: User

Create global temporary table tablename (
Col1 varchar2 (10 ),
Col2 number
) On commit preserve (delete) rows;

-- On commit Delete rows indicates that the temporary table is specified by a transaction. After each commit, Oracle truncates the table (delete all rows)
---------------------------------------
In Oracle8i, you can create two types of temporary tables:
1. Session-specific temporary table
Create global temporary <table_name> (<column specification>)
On commit preserve rows;

2. Temporary tables specific to transactions
Create global temporary <table_name> (<column specification>)
On commit Delete rows;
Create global temporary table mytemptable
Although the created temporary table exists, you can try to insert a record and then mount it to select using other connections. The record is empty.
The following two sentences will be added:
-- On commit Delete rows indicates that the temporary table is specified by a transaction. After each commit, Oracle truncates the table (delete all rows)
-- On commit preserve rows indicates that the temporary table is specified by the session. When the session is interrupted, Oracle truncates the table.

Procedure executes a series of operations
A package can define some quantities, functions, and processes;

DDL statements cannot be directly used in Stored Procedures, so dynamic SQL statements can only be used for execution.

Create procedure pro
As
STR varchar2 (100 );
Begin

STR: = 'Create Global temporary table admin_work_area
(Startdate date,
Enddate date,
Class char (20 ))
On commit Delete rows ';
Execute immediate STR;
End;
/

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.