Applied Biosystems SQL*LIMS Technical Support Technical Note Document Number: DBA003 Last Revised: 5//2003 Software Versions: SQL*LIMS v4.0.6 and v4. Author: Deborah Man Subject: How to check storage space in the database and increase space if required Description: It is good practice to check regularly that an Oracle instance has ample storage space, especially since the SQL*LIMS information management system can grow rapidly in use. The tablespaces and datafiles set up at installation might not be able to cope with the increasing demand for storage space over time. This article explains how to monitor space utilization and add more storage space when needed. Errors: If the SQL*LIMS tablespace is almost full and fails to allocate another extent for a table segment, the database operation executed by the SQL command will not occur. An error message will be displayed on the screen and/or be placed in log files or the alert log. Some example error messages are: ORA-0653: Unable to extend table <name.name> by <num> in tablespace <name> PEN-6002: Error during the insertion of <object> [e.g., Attributes or Samples] These errors do not necessarily indicate that you are totally out of space in the tablespace. They do indicate that Oracle cannot find a large enough area of free contiguous space for the next extent. Diagnostic Steps:. In Oracle Enterprise Manager, the Storage Manager client interface provides updated usage information for tablespaces (first figure) and datafiles (second figure).
2. You can also use the Oracle tool DBA Studio to view the storage space status. The views are similar to those in the Storage Manager (shown above). 3. Use the following SQL*Plus scripts to display a snapshot of your storage space. a. Oracle Technical Note ID# 020090.6 presents useful scripts to report space available in a tablespace. (Please refer to that technical note for more information.) To obtain information about the free space in a tablespace, examine DBA_FREE_SPACE, DBA_DATA_FILES, DBA_SEGMENTS, and DBA_EXTENTS. SQL> select a.tablespace_name, sum(a.tots) Tot_Size, sum(a.sumb) Tot_Free, sum(a.sumb)*00/sum(a.tots) Pct_Free, sum(a.largest) Max_Free, sum(a.chunks) Chunks_Free from (select tablespace_name,0 tots,sum(bytes) sumb, max(bytes) largest,count(*) chunks from dba_free_space a group by tablespace_name union select tablespace_name,sum(bytes) tots,0,0,0 from dba_data_files group by tablespace_name) a group by a.tablespace_name;
A sample output is: TABLESPACE_NAME TOT_SIZE TOT_FREE PCT_FREE MAX_FREE CHUNKS_FREE DRSYS INDX RBS SQLLIMS SQLLIMS_INDEX SQLLIMS_MULTIMEDIA SQLLIMS_QA SQLLIMS_TEMPORARY SYSTEM TEMP TOOLS USERS 20,97,520 20,97,520 73,400,320 04,857,600 04,857,600 04,857,600 20,97,520 4,943,040 27,843,328 20,97,520 0,485,760 20,97,520 6,965,632 44,032,000 78,487,552 84,484,096 03,743,488 20,635,648 33,742,848 393,26 0,477,568 8 00 60 75 8 99 98 80 0 00 00 00 b. To obtain information about extents, use this check_nextextent.sql script: 6,965,632 32,505,856 78,487,552 84,484,096 03,743,488 20,635,648 3,694,848 327,680 9,78,44 0,477,568 /* File: check_nextextent.sql This script takes into account Dictionary Managed Tablespaces as well as Locally Managed Tablespaces. This tip also takes into account whether a datafile is set to Autoextend ON. Oracle versions tested: 8..6, 8..7 and 9.0., and it will also work on 9.2. -- ================================= -- Modification History -- --------------------------------- 2-Apr-2003 JAZollars Modified formatting 6-Apr-2003 Sanjay Gupta Original */ Set Linesize 30 Set Trims on Column Tablespace Format A30 Column SegmentType Format A2 Column Owner Format A2 Column Segment Format A30 Column "Required Extent(KB)" Format 999,999,999.99 Column "MaxAvail(KB)" Format 999,999,999.99 SELECT /*+ RULE */ seg.tablespace_name "Tablespace", seg.segment_type "SegmentType", ext.owner, ext.segment_name "Segment", DECODE (freespace.extent_management, 'DICTIONARY', DECODE (seg.extents,, seg.next_extent, 'LOCAL', ext.bytes * ( + seg.pct_increase / 00) ), DECODE (freespace.allocation_type, 'UNIFORM', freespace.initial_extent, 'SYSTEM', ext.bytes) ) / 024 AS "Required Extent(KB)", freespace.largest / 024 "MaxAvail(KB)" FROM dba_extents ext, dba_segments seg, ( SELECT /*+ RULE */ maxsize_perfile.tablespace_name, tbs.extent_management, tbs.allocation_type, tbs.initial_extent, tbs.next_extent, 0 3 2 20
MAX (maxsize_perfile.maxsizebytes) AS largest FROM ( SELECT /*+ RULE */ ddf.tablespace_name, ddf.file_id, DECODE ( autoextensible, 'YES', (ddf.maxbytes - ddf.bytes), 0 ) + NVL (MAX (dfs.bytes), 0) AS maxsizebytes, NVL (MAX (dfs.bytes), 0) AS maxfreeextentsizebytes FROM dba_free_space dfs, dba_data_files ddf, dba_tablespaces tbsp WHERE dfs.file_id(+) = ddf.file_id AND tbsp.tablespace_name = ddf.tablespace_name AND tbsp.contents = 'PERMANENT' AND tbsp.status = 'ONLINE' GROUP BY ddf.tablespace_name, ddf.file_id, DECODE ( autoextensible, 'YES', (ddf.maxbytes - ddf.bytes), 0) ) maxsize_perfile, dba_tablespaces tbs WHERE maxsize_perfile.tablespace_name = tbs.tablespace_name AND tbs.status = 'ONLINE' GROUP BY maxsize_perfile.tablespace_name, tbs.extent_management, tbs.allocation_type, tbs.initial_extent, tbs.next_extent) freespace WHERE seg.owner = ext.owner AND seg.segment_type = ext.segment_type AND seg.segment_name = ext.segment_name AND seg.tablespace_name = ext.tablespace_name AND seg.extents - = ext.extent_id AND seg.tablespace_name = freespace.tablespace_name AND DECODE (freespace.extent_management, 'DICTIONARY', DECODE (seg.extents,, (seg.next_extent), ext.bytes * ( + seg.pct_increase / 00) ), 'LOCAL', DECODE (freespace.allocation_type, 'UNIFORM', freespace.initial_extent, 'SYSTEM', ext.bytes) ) > freespace.largest ORDER BY seg.tablespace_name, seg.segment_type, seg.segment_name / If the check_nextextent.sql script returns no rows, it means that the database has enough extents for growth next time. If it returns one or more rows, the tables or indexes listed will have a problem when they next try to extend. A sample output in the latter case is: Tablespace SegmentType OWNER Segment RequiredExtent (KB) MaxAvail (KB) SQLLIMS NESTED TABLE OPS$PENLIMS LRH_ATTRIBUTES 2,520.00 2,368.00 SQLLIMS NESTED TABLE OPS$PENLIMS RESULT_ATTRIBUTES 2,520.00 2,368.00 SQLLIMS NESTED TABLE OPS$PENLIMS TASK_ATTRIBUTES 3,780.00 2,368.00 SQLLIMS TABLE OPS$PENLIMS NAI_RESULTS 24,300.00 2,368.00 In this example, the SQLLIMS tablespace will run out of extents in the segments LRH_ATTRIBUTES, RESULT_ATTRIBUTES, TASK_ATTRIBUTES, and NAI_RESULTS. The respective required extents as compared with the largest freespace available are displayed so that you can determine the size of the datafile to be added to cope with the demand. This script warns you of any immediate space problem. It is advisable to run this script on a weekly basis, especially for a production environment.
Providing more space for your database: The following steps can be performed separately to provide more space:. If the extents are adjacent to each other, you can manually coalesce the adjacent free extents: ALTER TABLESPACE <tablespace name> COALESCE; 2. If you have enough disk space, add a datafile: ALTER TABLESPACE <tablespace name> ADD DATAFILE '<full path and file name>' SIZE <integer>; For example: ALTER TABLESPACE SQLLIMS ADD DATAFILE '/space/limsdata/lims6/sqllims_tablespace02.dbf' SIZE 200M; 3. If you have enough disk space, resize the datafile: ALTER DATABASE DATAFILE '<full path and file name>' RESIZE <integer> <k m>; Adding and resizing datafiles are the most direct and effective ways to fix the storage space problem. 4. If you have enough disk space, enable AUTOEXTEND: ALTER DATABASE DATAFILE <full path and file name> AUTOEXTEND ON MAXSIZE UNLIMITED; This temporary measure may not work if the tablespace is almost full. 5. Defragment the tablespace: Perform an export and then an import of the database to reorganize the tablespace. Then run the v4. to v4. migration procedures to revalidate all the synonyms, views, and packages.