create global temporary table : Temporary Table « Table « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> create table t ( x int );

Table created.

SQL>
SQL> create global temporary table sess_event
  2  on commit preserve rows
  3  as
  4  select * from v$waitstat
  5  where 1=0
  6  /

SQL>
SQL> truncate table sess_event;

Table truncated.

SQL>
SQL> insert into sess_event
  2  select * from v$waitstat
  3  /

18 rows created.

SQL>
SQL> begin
  2          for i in 1 .. 100000
  3          loop
  4                  insert into t values ( i );
  5                  commit ;
  6          end loop;
  7  end;
  8  /

PL/SQL procedure successfully completed.

SQL>
SQL> select a.class, b.count-a.count count, b.time-a.time time
  2    from sess_event a, v$waitstat b
  3   where a.class = b.class
  4  /


CLASS                   COUNT       TIME
------------------ ---------- ----------
data block                  0          0
sort block                  0          0
save undo block             0          0
segment header              0          0
save undo header            0          0
free list                   0          0
extent map                  0          0
1st level bmb               0          0
2nd level bmb               0          0
3rd level bmb               0          0
bitmap block                0          0
bitmap index block          0          0
file header block           0          0
unused                      0          0
system undo header          0          0
system undo block           0          0
undo header                 0          0
undo block                  0          0

18 rows selected.

SQL> drop table t;

Table dropped.








6.20.Temporary Table
6.20.1.create global temporary table
6.20.2.Global temporary table and connection
6.20.3.create global temporary table transaction_tab on commit delete rows
6.20.4.Create a temporary table whose rows will be deleted at the end of a session by specifying ON COMMIT PRESERVE ROWS
6.20.5.Using Varrays in Temporary Tables