Temporary Tablespaces and Tempfiles

4
TEMPORARY Tablespaces and TEMPFILES Submitted by admin on Thu, 2003-06-19 02:28 RDBMS Server What are Temporary Tablespaces: Temporary tablespaces are used to manage space for database sort operations and for storing global temporary tables. For example, if you join two large tables, and Oracle cannot do the sort in memory (see SORT_AREA_SIZE initialisation parameter), space will be allocated in a temporary tablespace for doing the sort operation. Other SQL operations that might require disk sorting are: CREATE INDEX, ANALYZE, Select DISTINCT, ORDER BY, GROUP BY, UNION, INTERSECT, MINUS, Sort-Merge joins, etc. The DBA should assign a temporary tablespace to each user in the database to prevent them from allocating sort space in the SYSTEM tablespace. This can be done with one of the following commands: SQL> CREATE USER scott DEFAULT TABLESPACE data TEMPORARY TABLESPACE temp; SQL> ALTER USER scott TEMPORARY TABLESPACE temp; Note that a temporary tablespace cannot contain permanent objects and therefore doesn't need to be backed up. What are TEMPFILES? Unlike normal data files, TEMPFILEs are not fully initialised (sparse). When you create a TEMPFILE, Oracle only writes to the header and last block of the file. This is why it is much quicker to create a TEMPFILE than to create a normal database file. TEMPFILEs are not recorded in the database's control file. This implies that one can just recreate them whenever you restore the database, or after deleting them by accident. This opens interesting possibilities like having different TEMPFILE configurations between permanent and standby databases, or

description

tt

Transcript of Temporary Tablespaces and Tempfiles

TEMPORARY Tablespaces and TEMPFILESSubmitted by admin on Thu, 2003-06-19 02:28 RDBMS ServerWhat are Temporary Tablespaces:Temorary tab!e"a#e" are u"ed to mana$e "a#e %or databa"e "ort oeration" and %or "torin$ $!oba! temorary tab!e"& 'or e(am!e, i% you )oin t*o !ar$e tab!e", and +ra#!e #annot do the "ort in memory ,"ee S+RT-.R/.-S01/ initia!i"ation arameter2, "a#e *i!! be a!!o#ated in a temorary tab!e"a#e %or doin$ the "ort oeration& +ther S34 oeration" that mi$ht re5uire di"6 "ortin$ are: 7R/.T/ 08D/9, .8.4:1/, Se!e#t D0ST087T, +RD/R B:, ;R+ ALTER DATABASE TEMPFILE '/oadata/temp!"#d$%' DROP I&CLUDI&' DATAFILES;0% you remove a!! tem%i!e" %rom a temorary tab!e"a#e, you may en#ounter error: +R.-2A1A3: Temorary Tab!e"a#e i" /mty& CREATE TEMPORARY TABLESPACE temp TEMPFILE '/oadata/m+temp,!*#tmp' SI)E "!ME-TE&T MA&A'EME&T LOCAL U&IFORM SI)E *.M;'or be"t er%orman#e, the