11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

134 CHAPTER 3 ■ DATABASE ADMINISTRATIONtempfiles and to specify a temporary tablespace during the creation of temporary tables. We’llcover both of the temporary tablespace innovations in more detail in the following sections.Shrinking Temporary Tablespaces and TempfilesOften you’ll find you need to reduce the space that you had allocated to the temporary tablespace.It’s not uncommon to see huge tempfiles floating around on disk, even after a massive sort jobhas finished. You have increased the allocation temporarily for a large job and want to reclaimthe space after the job is completed. In previous releases of the <strong>Oracle</strong> database, you just couldn’tdo this, because there was no way to reduce the size of the temporary tablespace. You coulddrop the large temporary tablespace and re-create it with a smaller size, but you have to ensurethat the users aren’t using the temporary tablespace for sorting operations during that time.In <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g, you can shrink the temporary tablespace by specifying the newclause shrink space in an alter tablespace statement. You can also shrink tempfiles using thenew command alter tablespace shrink tempfile, thus making the temporary tablespacesmaller. Here are a couple of examples, the first one showing how to shrink a temporary tablespaceand the second showing how to shrink a tempfile:SQL> alter tablespace temp shrink space;SQL> alter tablespace temp shrinktempfile '/u01/app/oracle/oradata/or<strong>11</strong>/temp01.dbf';If you have multiple datafiles in the temporary tablespace, the shrink space clause willshrink all the tempfiles to a database-determined minimum size, which is about 1m. Theminimum size the tablespaces are shrunk to take into account the tablespace storage requirements.If you want the temporary tablespace/tempfile to be at least a certain size, you can usethe keep clause to specify a lower bound for the tablespace/tempfile, as shown in the examplehere, which shrinks the temporary tablespace named temp.SQL> alter tablespace temp shrink spacekeep 100m;In the keep clause in this example, 100m is the value for the size subclause. Let’s look atthe logic <strong>Oracle</strong> uses to shrink the temp tablespace. In the following example, there are two1GB tempfiles. The command to shrink the temp tablespace to 1GB was issued immediatelyafterward.SQL> alter database tempfile '+DATA/o<strong>11</strong>g/tempfile/temp.263.617809819'resize 1000m;<strong>Database</strong> altered.SQL> alter database tempfile '+DATA/o<strong>11</strong>g/tempfile/temp.290.618408247'resize 1000m;<strong>Database</strong> altered.SQL> alter tablespace temp shrink space keep 1000m;Tablespace altered.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!