Notifications
Clear all

[Solved] How do you see Oracle tablespace usage and increase tablespace size?

2 Posts
2 Users
2 Reactions
2,227 Views
0
Topic starter

The default install of Oracle runs out of space for me every 6 months or so and I end up having to increase the tablespace. Is there an easy way to do this?

2 Answers
1
Topic starter

To see your tablespace usage login as system user and run this SQL:

SELECT b.tablespace_name,
  tbs_size SizeMb,
  a.free_space FreeMb
FROM
  (SELECT tablespace_name,
    ROUND(SUM(bytes)/1024/1024 ,2) AS free_space
  FROM dba_free_space
  GROUP BY tablespace_name
  ) a,
  (SELECT tablespace_name,
    SUM(bytes)/1024/1024 AS tbs_size
  FROM dba_data_files
  GROUP BY tablespace_name
  ) b
WHERE a.tablespace_name(+)=b.tablespace_name;

Here we see i am out of space on "SYSTEM"

 image 1

To increasing the tablespace can be done through the "Oracle SQL Developer" GUI. Select "View->DBA"

 image 1

In the "DBA" panel that opens add a connection for the "SYSTEM" or administrative oracle user. Then select "Storage->Tablespaces".

 image 1

Right click on the tablespace which has run out of space. Check unlimited and click "OK".

 image 1
1

Another option for increasing tablespace size:

In sqlplus, run the following as SYSTEM:

SET LINESIZE 200;
select 'alter database datafile '''||    file_name||    ''' '||    ' autoextend on maxsize unlimited;' from    dba_data_files;

This will spit out lines like the following. Copy and paste those lines to execute them.

alter database datafile 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\USERS.DBF'  autoextend on maxsize unlimited;
alter database datafile 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSAUX.DBF'  autoextend on maxsize unlimited;
alter database datafile 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\UNDOTBS1.DBF'  autoextend on maxsize unlimited;
alter database datafile 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSTEM.DBF'  autoextend on maxsize unlimited;