You are on page 1of 1

Extending Oracle Tablespace Quick and Dirty

Posted on 12 September 2010 Tags: PL/SQL, Tablespace


I was working on quick project and kept bumping an a failure to initiate auto-extend message that was rather irritating. I typically use SQLDeveloper over Toad and there is not immediate built-in functionality to manage tablespaces in that tool. A quick Google search gave me some results and I figured I would quickly post the two step extension process here for later reference.

Step 1
Run the PL/SQL code to determine the current size of the tablespace in question. Notice how memory is divided by 1024 to get at the canonical data size. The tablespace I was using for my project was the SYSTEM tablespace and it is referenced within the code in this post. If you are using the USERS or a custom tablespace simple substitute your tablespace where you see SYSTEM. view sourceprint? 01.select 02.file_name, 03.autoextensible, 04.(bytes/1024)/1024 usedmb, 05.(maxbytes/1024)/1024 maxmb, 06.round((((bytes/1024)/1024) 07./ ((maxbytes/1024)/1024)) * 100) used_pct 08.from dba_data_files 09.where tablespace_name = 'SYSTEM';

Step 2
As we determined in the previous step, we now know how much of the tablespace is being used and what the current size and max sizes are. To extend the space run the following query based on the information provided from the Step 1. I want to increase my maxsize to a value that I know is within the bounds of my current volume but will still allow my data operations to continue without being held hostage by the error that started this discussion. To do that I pick a value such as 2000 MB and multiple it twice by 1024 (i.e.: 2000 x 1024 x 1024) . The result of that math is the value I place for the maxsize in the following statement. view sourceprint? 1.alter database datafile 'G:\ORACLEXE\ORADATA\XE\SYSTEM.DBF' autoextend on maxsize 2097152000; Run the statement above and the tablespace maxsize will be set as desired. Re-run the statement provided in Step 1 to see the values have changed and your percentage of use should now be changed as well.

You might also like