oracle system -15.2- temporary table space

Temporary table space

Effect: for caching data sorting (intermediate results)

You can create multiple temporary table space, but the default temporary table space can only have one and can not be offline and drop. temp table space is nologing of (non-logged).

SQL> select file_id,file_name,tablespace_name from dba_temp_files;

FILE_ID FILE_NAME                             TABLESPACE_NAME

---------- -------------------------------------------------- ------------------------------

1     /u01/oradata/prod/temp01.dbf              TEMP

SQL> col name for a60;

SQL> select file#,name ,bytes/1024/1024 from v$tempfile;

FILE# NAME                                       BYTES/1024/1024

---------- -------------------------------------------------- ---------------

1    /u01/oradata/prod/temp01.dbf                  100

Basic Operations

1 ) the establishment of a temporary table space temp2 . Add or remove tempfile .

SQL> create temporary tablespace temp2 tempfile '/u01/oradata/prod/temp02.dbf' size 10m;

SQL> alter tablespace temp2 add tempfile '/u01/oradata/prod/temp03.dbf' size 5m;

SQL> select file_id,file_name,tablespace_name from dba_temp_files;

FILE_ID FILE_NAME                                TABLESPACE_NAME

---------- -------------------------------------------------------------------------------- -----------------------

1     /u01/oradata/prod/temp01.dbf                     TEMP

2     /u01/oradata/prod/temp02.dbf                     TEMP2

3     /u01/oradata/prod/temp03.dbf                     TEMP2

The temp2 was deleted a tempfile .

SQL> alter tablespace temp2 drop tempfile '/u01/oradata/prod/temp03.dbf';

SQL> select file_id,file_name,tablespace_name from dba_temp_files;

2 ) Check the default temporary table space

SQL> select * from database_properties where rownum<=5;

3) Use the specified user temporary table space

SQL> alter user scott temporary tablespace temp2;  

4) switching the default temporary tablespace

SQL> alter database default temporary tablespace temp2;

 Temporary table space group

In many cases, there are multiple session to use the same user name to access the Oracle , the temporary table space is user-based, you can create a temporary table space group,

Group made up of several members of the temporary table space, thereby improving the efficiency of a single user using a plurality of sessions temporary table space.

1 ) Temporary tablespace group can not be created explicitly, the group is automatically created when first assigned by the temporary table space.

SQL> alter tablespace temp1 tablespace group tmpgrp;

SQL> alter tablespace temp2 tablespace group tmpgrp;

SQL> select * from dba_tablespace_groups;

GROUP_NAME                     TABLESPACE_NAME

------------------------------ ------------------------------

TMPGRP temp1

TMPGRP                          TEMP2

The SQL> ALTER TABLESPACE User Scott Temporary tmpgrp;   ## users to join the group

The SQL> SELECT USERNAME, temporary_tablespace from DBA_USERS   WHERE username = 'SCOTT';   ## see scott whether to join the group tablespace

2 ) temporary tablespace group set to the default temporary table space, to achieve load balancing.

SQL> alter database default temporary tablespace tmpgr;

3 ) To remove the table space the group can not be the default temporary table space.

SQL> alter database default temporary tablespace temp;

SQL> alter tablespace temp1 tablespace group '';

SQL> alter tablespace temp2 tablespace group '';

4 ) When all temporary table spaces within the group is removed, the group is also automatically deleted.

SQL> select * from dba_tablespace_groups;

SQL> drop tablespace temp2 including contents and datafiles;

 

Guess you like

Origin www.cnblogs.com/yqp-1/p/12310236.html