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;
/