Professional Documents
Culture Documents
SOP For Tablespace Management
SOP For Tablespace Management
SOP For Tablespace Management
Oracle COE
SOP for Table Space Management
Author(s):
Diganta Sinha, Senior Oracle Apps DBA, Tata Consultancy Services Ltd, Port Macquarie, AU.
Sunil Agarwal, Database Analyst, Essential Energy Australia, Sydney.
Approver(s):
James Arnold, Oracle SDM, Melbourne, AU
Page 1 of 11
TCS Oracle COE Effective Date: 2nd Jan 2019
Global IT Base SOP for Table Space Management Revision: 1.0
Request fails with the following error; there can be several types of errors too.
We will see errors in alert log, and concurrent request will start failing.
You will get an alert from OEM or from customized scripts about the possible storage space
requirement on the tablespaces.
2) Use following query to determine the tablespace usage report. Try to find as much as
information about the tablespace as you can with below queries.
Query1:
SELECT tbs.tablespace_name,
tot.bytes / 1024 total,
tot.bytes / 1024 -SUM(nvl(fre.bytes, 0)) / 1024 used,
SUM(nvl(fre.bytes, 0)) / 1024 free,
(1 -SUM(nvl(fre.bytes, 0)) / tot.bytes) *100 pct,
decode(greatest((1 -SUM(nvl(fre.bytes, 0)) / tot.bytes) *100, 90), 90, '', '*') pct_warn
FROM dba_free_space fre,
(SELECT tablespace_name,
SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name)
tot,
dba_tablespaces tbs
WHERE tot.tablespace_name = tbs.tablespace_name
AND fre.tablespace_name(+) = tbs.tablespace_name
AND tbs.tablespace_name = '&tablespacename'
GROUP BY tbs.tablespace_name,
tot.bytes / 1024,
tot.bytes
ORDER BY 5, 1;
Query2:
set lines 1000;
set pages 1000;
column dummy noprint
column pct_used format 999.9 heading "%|Used"
column name format a21 heading "Tablespace Name"
column Kbytes format 999,999,999,999 heading "KBytes"
column used format 999,999,999,999 heading "Used"
column free format 999,999,999 heading "Free"
column largest format 999,999,999 heading "Largest"
column max_size format 999,999,999 heading "MaxPoss|Kbytes"
column pct_max_used format 999.9 heading "%|Max|Used"
break on report
compute sum of kbytes on report
compute sum of free on report
compute sum of used on report
Query3:
SELECT max(bytes) FROM dba_free_space WHERE tablespace_name = '<tablespace name>';
The above query returns the largest available contiguous chunk of space.
If this query is done immediately after the failure, it will show that the largest contiguous space in
the tablespace is smaller than the next extent the object was trying to allocate.
Query4:
Following Sql statement will generate tablespace usage report taking autoextend into
consideration:
Eg:
Use Query2:
One more point to remember, TRAX_SMALL_DATA is showing ZERO in above picture. Normally
we think, we need to add datafile but the assumption is wrong. Recommend to do proper
investigation.
How to investigate further, there is still space is available around 33238007808 (MAXBYTES
34359721984 – BYTES 1121714176).
In this case, don’t add any new datafile.
select ts.name||'|'||df.name||'|'||bytes/1024/1024||'|'||CREATE_BYTES/1024/1024
from v$tablespace ts, v$datafile df
where ts.ts#=df.ts#
and ts.name = 'APPS_TS_TX_IDX';
Now you have the list of existing datafiles, the new datafile name should follow the sequence
number in order and should use the next data mount point in the sequence.
Note: Data mount points should be used in a circular fashion.
For e.g if the output of above query is as below:
APPS_TS_TX_IDX|/prod/oradata/data01/prod/APPS_TS_TX_IDX01.dbf|2750|0
APPS_TS_TX_IDX|/prod/oradata/data02/prod/APPS_TS_TX_IDX02.dbf|4096|0
APPS_TS_TX_IDX|/prod/oradata/data03/prod/APPS_TS_TX_IDX03.dbf|3300|0
APPS_TS_TX_IDX|/prod/oradata/data04/prod/APPS_TS_TX_IDX04.dbf|4096|0
APPS_TS_TX_IDX|/prod/oradata/data05/prod/APPS_TS_TX_IDX05.dbf|3950|0
APPS_TS_TX_IDX|/prod/oradata/data01/prod/APPS_TS_TX_IDX06.dbf|4096|0
APPS_TS_TX_IDX|/prod/oradata/data02/prod/APPS_TS_TX_IDX07.dbf|3900|0
APPS_TS_TX_IDX|/prod/oradata/data03/prod/APPS_TS_TX_IDX08.dbf|4000|0
APPS_TS_TX_IDX|/prod/oradata/data04/prod/APPS_TS_TX_IDX09.dbf|3750|0
APPS_TS_TX_IDX|/prod/oradata/data05/prod/APPS_TS_TX_IDX10.dbf|3800|0
APPS_TS_TX_IDX|/prod/oradata/data01/prod/APPS_TS_TX_IDX11.dbf|4096|0
APPS_TS_TX_IDX|/prod/oradata/data02/prod/APPS_TS_TX_IDX12.dbf|3500|0
APPS_TS_TX_IDX|/prod/oradata/data03/prod/APPS_TS_TX_IDX13.dbf|2850|0
APPS_TS_TX_IDX|/prod/oradata/data04/prod/APPS_TS_TX_IDX14.dbf|3650|0
APPS_TS_TX_IDX|/prod/oradata/data05/prod/APPS_TS_TX_IDX15.dbf|2900|0
APPS_TS_TX_IDX|/prod/oradata/data01/prod/APPS_TS_TX_IDX16.dbf|3450|0
Important: Also we have 2 more mount points “system01” and “custom01”. The system01 mount
is used for system tablespaces and custom01 mount is used for other custom application
tablespaces. For tablespaces on these mount points we just need to increase the sequence
number and not the data mount. The dbf should be added on the mount where the other dbf’s are
present.
Confirm that file does not already exist and you have enough space in the mount point.
a) ls -l /prod/oradata/data02/prod/APPS_TS_TX_IDX17.dbf
--This should not list the data file.
b) df -k | grep /prod/oradata/data02
--The mount point should not be more then 90% used after creating a datafile, do the estimations
accordingly. If the mount point usage goes above 85% please inform the lead about the same.
C) Ensure that all the previous dbf’s are of size 4096 M. If you have a dbf of size less than 4096
MB jump to Step 5 - Scenario 1.
Scenario 1)
Check if an existing datafile can be extended by the amount required (if the datafile is not already
at 4GB). If datafile can be extended then use below command and skip Scenario 2:
A) For datafiles over 1000MB and < 4096M big Data & Indx Tablespaces Ex: INV, MRP, BOM,
FND, JTF, PO, GL, OKC, WSH, OSM, AR, ONT, ASO, OKSX, OKSD, use following:
alter database datafile '<file_name>' autoextend on next 50M maxsize 4096M;
Scenario 2)
Add new database file to tablespace shown in alert using command as given below:
A) For datafiles over 1000MB and < 4096M big Data & Indx Tablespaces Ex: INV, MRP, BOM,
FND, JTF, PO, GL, OKC, WSH, OSM, AR, ONT, ASO, OKSX, OKSD etc, use following:
alter tablespace <tablespace_name> add datafile '<file_name>' size 50M autoextend on next
50M maxsize 4096M;
The size of the datafile should be 4096MB, if more than 4096MB storage is required on the
tablespace then add another file of 4096MB at the same time or in the future as per the
requirement.
If tablespace is a small tablespace and growth of the tablespace is not much, then you can
add the datafile of size 2048m instead of 4096m.
Issue faced:
An "unable to extend" error is raised when there is insufficient contiguous space available to extend a segment.
1. Determine the largest contiguous space available for the tablespace with the error
SELECT max(bytes) FROM dba_free_space WHERE tablespace_name = '<tablespace
name>';
The above query returns the largest available contiguous chunk of space.
If this query is done immediately after the failure, it will show that the largest contiguous space in
the tablespace is smaller than the next extent the object was trying to allocate.
3. Compute the NEXT EXTENT SIZE if the segment resides in a dictionary managed tablespace
and has a PCT_INCREASE >0
Use the "next_extent" size with "pct_increase" (from #2 above) in the following formula to
determine the size of extent that is trying to be allocated.
EXAMPLE
next_extent = 512000
pct_increase = 50
4) Determine if the tablespace containing the object is AUTOEXTENSIBLE and has reached
MAXSIZ
Possible Solutions
C. Add a Datafile
ALTER TABLESPACE <tablespace name> ADD DATAFILE '<full path and file name>'
SIZE <integer> <k | m | g | t | p | e>;
For ORA-1654 errors, we can proactively monitor the issue before hand by using
the following script.
The following statement is executed in lab1. We can try to automate this using cron.
Eg:
SQL>
1 select owner,segment_name, segment_type, tablespace_name, extents, next_extent
2 ,to_char(next_extent,'999,999,999,999')||' will be requested but only '||
3 to_char(dfs_bytes,'999,999,999,999')||
4 ' is available.'||chr(10)||'Recommended Action : '||chr(10)||'alter '||segment_type||' '
5 ||owner||'.'||segment_name||
6 ' storage ( next '|| to_char(dfs_bytes,'999999999999')||' );' warning_text
7 from dba_segments
8 ,( select tablespace_name dfs_ts_name , max(bytes) dfs_bytes
9 from dba_free_space
10 group by tablespace_name )
11 where tablespace_name = dfs_ts_name
12 and next_extent > dfs_bytes
13* and owner not in ('SYS','SYSTEM')
SQL> /
Index altered.
no rows selected
select
srt.tablespace,
srt.segfile#,
srt.segblk#,
srt.blocks,
a.sid,
a.serial#,
a.username,
a.osuser,
a.status
from
v$session a,
v$sort_usage srt
where
a.saddr = srt.session_addr
order by
srt.tablespace, srt.segfile#, srt.segblk#,
srt.blocks;