Oracle's Default TEMPORARY Tablespaces - Page 2
October 10, 2003
The TEMPORARY Tablespace
You can create a TEMPORARY tablespace by issuing the statement in Listing 3. This is the simplest form of the CREATE TEMPORARY command. You may also issue a statement such as in Listing 4. The difference in the two statements is the specifying of the TEMPFILE location. In the first example, Oracle will use the initialization parameter DB_CREATE_FILE_DEST if specified. If this parameter is not specified you must use the statement in Listing 4 or the statement will fail. If you would like to set the DB_CREATE_FILE_DEST, just issue a statement such as that in Listing 5. If you are wondering how the files look for the tablespaces just created you can look at Listing 6.
The DEFAULT TEMPORARY Tablespace
The default temporary tablespace is nothing more than a temporary tablespace that has been designated a global temporary tablespace for all users that have not been explicitly defined a temporary tablespace at user creation time. You can specify a default temporary tablespace by issuing a statement such as in Listing 7.
Now if we were to create a user, their temporary tablespace would be TEMP01. The best thing about using default temporary tablespaces is that if you were to switch the default temporary tablespace, all users that were assigned the initial default temporary tablespace would inherit the new default temporary tablespace. Take a look at Listing 8 to see the progression of switching a default temporary tablespace and the users' inheriting it.
The DEFAULT Tablespace
Ok, too much of a good thing. Now the last remaining problem with creation of a user is the DEFAULT tablespace. When we create a user and do not specify the default tablespace, the user is assigned the SYSTEM tablespace. Look at Listing 9. I personally will look to Oracle to change this very soon. I understand the reasoning behind assigning temporary tablespaces and default tablespaces to the SYSTEM tablespace in earlier versions. Most of the systems were not that large and many installations were just running with the SYSTEM tablespace. The unfortunate thing is that today, a single tablespace cannot hold all the data and performance is much more important in the systems of today.
In previous releases of Oracle, if you forgot to assign a
temporary tablespace to a user, the SYSTEM tablespace was used. This could and
did cause some major contention and performance issues. Oracle has always
stated that it was a bad practice to assign the SYSTEM tablespace to a users'
default or temporary tablespace. While getting the DEFAULT tablespace
assignment still requires some intervention, the assigning of a TEMPORARY
tablespaces has become a bit less worrisome.