Temporary Tablespace and Temporary Table

Temporary Tablespaces: (sort segments and temp table data segments)

          1.contains transient data that persists only for the duration of the session.         

          2.improve the concurrency of multiple sort operations, reduce their overhead, and avoid Oracle Database space management operations.

          3.A temporary tablespace can be assigned to users with the CREATE USER or ALTER USER statement and can be shared by multiple users.

          4.Within a temporary tablespace, all sort operations for a given instance and tablespace share a single sort segment.  An extent cannot be shared by multiple transactions.

          5.When you create a temporary table, its rows are stored in your default temporary tablespace.

          6. V$SORT_SEGMENT view,V$TEMPSEG_USAGE,v$tempfile,v$dba_temp_files

1.create temporary tablespace temp1 tempfile '/u01/oradata/lsh/tempfile.dbf' size 100m extent management local uniform size 10m;

 

2.alter tablespace temp1 tempfile offline/online ;alter database tempfile '/u01/oradata/lsh/tempfile.dbf' offline/online;

 

3.alter tablespace temp1 add  tempfile '/u01/oradata/lsh/tempfile01.dbf' size 100m; alter database tempfile '/u01/oradata/lsh/tempfile.dbf' resize 150m;

 

4.alter database tempfile '/u01/oradata/lsh/tempfile.dbf' drop including datafiles;               

 

 Temporary Table:    

            1.The definition of a temporary table is visible to all sessions  

            2. the data in a temporary table is visible only to the session that inserts the data into the table

            3.The ON COMMIT clause indicate if the data in the table is transaction-specific (the default) or session-specific, the implications of which are as follows:

ON COMMIT Setting Implications
DELETE ROWS This creates a temporary table that is transaction specific. A session becomes bound to the temporary table with a transactions first insert into the table. The binding goes away at the end of the transaction. The database truncates the table (delete all rows) after each commit.
PRESERVE ROWS This creates a temporary table that is session specific. A session gets bound to the temporary table with the first insert into the table in the session. This binding goes away at the end of the session or by issuing a TRUNCATE of the table in the session. The database truncates the table when you terminate the session.

CREATE GLOBAL TEMPORARY TABLE admin_work_area
        (startdate DATE,
         enddate DATE,
         class CHAR(20))
      ON COMMIT DELETE ROWS;

你可能感兴趣的:(tablespace)