Tablespaces guide
Tablespaces guide
Datafiles
An Oracle database is comprised of tablespaces.
Tablespace Types
There are three types of tablespaces: (1) permanent, (2) undo, and (3)
temporary.
Permanent – These tablespaces store objects in segments that are
permanent – that persist beyond the duration of a session or
transaction.
Undo – These tablespaces store segments that may be retained
beyond a transaction, but are basically used to:
o Provide read consistency for SELECT statements that access
tables that have rows that are in the process of being modified.
o Provide the ability to rollback a transaction that fails to commit.
Temporary – This tablespace stores segments that are transient and
only exist for the duration of a session or a transaction. Mostly, a
temporary tablespace stores rows for sort and join operations.
As you can see, almost all of the clauses are optional. The clauses are
defined as follows:
DATAFILE
'/u01/student/dbockstd/oradata/USER350data01.dbf' SIZE
10M
Locally Managed
The extents allocated to a locally managed tablespace are managed
through the use of bitmaps.
Each bit corresponds to a block or group of blocks (an extent).
The bitmap value (on or off) corresponds to whether or not an extent
is allocated or free for reuse.
Local management is the default for the SYSTEM tablespace beginning
with Oracle 10g.
When the SYSTEM tablespace is locally managed, the other
tablespaces in the database must also be either locally managed or
read-only.
Local management reduces contention for the SYSTEM tablespace
because space allocation and deallocation operations for other
tablespaces do not need to use data dictionary tables.
The LOCAL option is the default so it is normally not specified.
Extent Management
UNIFORM – a specification of UNIFORM means that the tablespace
is managed in uniform extents of the SIZE specified.
o use UNIFORM to enable exact control over unused space and
when you can predict the space that needs to be allocated for an
object or objects.
o Use K, M, G, T, etc to specify the extent size in kilobytes,
megabytes, gigabytes, terabytes, etc. The default is 1M; however,
you can specify the extent size with the SIZE clause of
the UNIFORM clause.
o For our small student databases, a good SIZE clause value
is 128K.
o You must ensure with this setting that each extent has at least 5
database blocks.
AUTOALLOCATE – a specification of AUTOALLOCATE instead
of UNIFORM, then the tablespace is system managed and you
cannot specify extent sizes.
o AUTOALLOCATE is the default.
this simplifies disk space allocation because the database
automatically selects the appropriate extent size.
this does waste some space but simplifies management of
tablespace.
o Tablespaces with AUTOALLOCATE are allocated minimum extent
sizes of 64K with a minimum of 5 database blocks per extent.
Possible Errors
You cannot specify the following clauses when you explicitly specify
EXTENT MANAGEMENT LOCAL:
o DEFAULT storage clause
o MINIMUM EXTENT
o TEMPORARY
MANUAL: This setting uses free lists to manage free space within
segments.
o Free lists are lists of data blocks that have space available for
inserting rows.
o You must specify and tune the PCTUSED, FREELISTS, and
FREELIST GROUPS storage parameters.
o MANUAL is usually NOT a good choice.
AUTO: This uses bitmaps to manage free space within segments.
o This is the default.
o A bitmap describes the status of each data block within a
segment with regard to the data block's ability to have
additional rows inserted.
o Bitmaps allow Oracle to manage free space automatically.
o Specify automatic segment-space management only for
permanent, locally managed tablespaces.
o Automatic generally delivers better space utilization than
manual, and it is self-tuning.
Dictionary Managed
With this approach the data dictionary contains tables that store information
that is used to manage extent allocation and deallocation manually.
NOTE: Keep in mind you will NOT be able to create any tablespaces
of this type in your 11g database. This information is provided in the
event you have to work with older databases.
UNDO Tablespace
The Undo tablespace is used for automatic undo management. Note the
required use of the UNDO clause within the CREATE command shown in
the figure here.
More than one UNDO tablespace can exist, but only one can be active at a
time.
TEMPORARY Tablespace
A TEMPORARY tablespace is used to manage space for sort
operations. Sort operations generate segments, sometimes large
segments or lots of them depending on the sort required to satisfy the
specification in a SELECT statement's WHERE clause.
Sort operations are also generated by SELECT statements that join rows
from within tables and between tables.
This should raise a red flag as you don't want system users to execute
SELECT commands that cause sort operations to take place within the
SYSTEM
tablespace.
After this, new system user accounts are automatically allocated temp as
their temporary tablespace. If you ALTER DATABASE to assign a new
default temporary tablespace, all system users are automatically
reassigned to the new default tablespace for temporary operations.
Limitations:
A default temporary tablespace cannot be dropped unless a
replacement is created. This is usually only done if you were moving
the tablespace from one disk drive to another.
You cannot take a default temporary tablespace offline – this is done
only for system maintenance or to restrict access to a tablespace
temporarily. None of these activities apply to default temporary
tablespaces.
You cannot alter a default temporary tablespace to make it
permanent.