Thursday, September 5, 2019

Adding a Datafile/Tempfile to Temp Tablespace



Connect with oracle database and check tempfile location & information :

[oracle@localhost ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.2.0.1.0 Production on Thu Sep 5 14:58:33 2019

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> set pages 999
set lines 400
col FILE_NAME format a50
col TABLESPACE_NAME format a10
select d.TABLESPACE_NAME, d.FILE_NAME, d.BYTES/1024/1024 SIZE_MB, d.AUTOEXTENSIBLE, d.MAXBYTES/1024/1024 MAXSIZE_MB, d.INCREMENT_BY*(v.BLOCK_SIZE/1024)/1024 INCREMENT_BY_MB
from dba_temp_files d,
 v$tempfile v
where d.FILE_ID = v.FILE#
order by d.TABLESPACE_NAME, d.FILE_NAME;SQL> SQL> SQL> SQL>   2    3    4    5

TABLESPACE FILE_NAME                                             SIZE_MB AUT MAXSIZE_MB INCREMENT_BY_MB
---------- -------------------------------------------------- ---------- --- ---------- ---------------
TEMP       /u01/app/oracle/oradata/risdev/temp01.dbf                  32 YES 32767.9844            .625

SQL>


Add tempfile to temp tablepsace : 

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/risdev/temp02.dbf' SIZE 5G AUTOEXTEND ON NEXT 1G MAXSIZE 32767M;

Tablespace altered.

SQL>



Verify added tempfile : 



SQL> set pages 999
set lines 400
col FILE_NAME format a50
col TABLESPACE_NAME format a10
select d.TABLESPACE_NAME, d.FILE_NAME, d.BYTES/1024/1024 SIZE_MB, d.AUTOEXTENSIBLE, d.MAXBYTES/1024/1024 MAXSIZE_MB, d.INCREMENT_BY*(v.BLOCK_SIZE/1024)/1024 INCREMENT_BY_MB
from dba_temp_files d,
 v$tempfile v
where d.FILE_ID = v.FILE#
order by d.TABLESPACE_NAME, d.FILE_NAME;SQL> SQL> SQL> SQL>   2    3    4    5

TABLESPACE FILE_NAME                                             SIZE_MB AUT MAXSIZE_MB INCREMENT_BY_MB
---------- -------------------------------------------------- ---------- --- ---------- ---------------
TEMP       /u01/app/oracle/oradata/risdev/temp01.dbf                  32 YES 32767.9844            .625
TEMP       /u01/app/oracle/oradata/risdev/temp02.dbf                5120 YES      32767            1024

SQL>



* Make sure enough space available at mount point .

Query:

set pages 999
set lines 400
col FILE_NAME format a50
col TABLESPACE_NAME format a10
select d.TABLESPACE_NAME, d.FILE_NAME, d.BYTES/1024/1024 SIZE_MB, d.AUTOEXTENSIBLE, d.MAXBYTES/1024/1024 MAXSIZE_MB, d.INCREMENT_BY*(v.BLOCK_SIZE/1024)/1024 INCREMENT_BY_MB
from dba_temp_files d,
 v$tempfile v
where d.FILE_ID = v.FILE#

order by d.TABLESPACE_NAME, d.FILE_NAME;

No comments:

Post a Comment