Professional Documents
Culture Documents
Tablespaces are used to organise tables and indexes into manageable groups, tablespaces themselves are made
up of one for more data/temp files.
• Permanent - uses data files and normally contain the system and users data
• Temporary - are used to store objects for the duration of a users session, temp files are used to create
temporary tablespaces
• Undo - are a permanent type of tablespace that are used to store undo data which if required would undo
changes of data by users
• Readonly - are permanent tablespace that can only be read, no writes can take place, but the tablespace
can be made read/write.
• System - is a permanent tablespace and contains the vital data dictionary (metadata about the database)
• Sysaux - is an auxiliary tablespaces and contains performance statistics collected by the database.
Tablespace Management
Extents are the basic unit of a tablespace (see Oracle structure.doc under data_files for more
details) and are managed in bitmaps that are kept within the data file header for all the blocks
within that datafile. For example if a tablespace is made up of 128KB extents, each 128KB extent
is represented by a bit in the extent bitmap for this file, the bitmap values indicate if the extent is
used or free. The bitmap is updated when the extent changes there is no updating or any data
dictionary tables thus increasing performance.
Locally Extents are tracked via bitmaps not using recursive SQL.
(default)
Locally managed tablespaces cannot be converted into a dictionary managed one. The benefits of
using a local managed tablespace
There are a number of things that you should know about tablespaces.
Tablespaces -2-
Extent Management
Anytime an object needs to grow in size space is added to that object by extents. When you are using locally
managed tablespaces there are two options that the extent size can be managed
This means the extent will vary in size, the first extent starts at 64k and progessively increased
to 64MB by the database. The database automatically decides what size the new extent will be
Autoallocate based on segment growth patterns.
(default)
Autoallocate is useful if you aren't sure about growth rate of an object and you let oracle
decide.
Create the extents the same size by specifying the size when create the tablespace.
This is default for temporary tablespace but not available for undo tablespaces.
Uniform
Becareful with uniform as it can waste space, use this option you are know what the growth
rate of the objects are going to be.
Segment space management is how oracle deals with free space with in an oracle data block. The segment space
management you specify at tablespace creation time applies to all segments you later create in the tablespace.
Oracle manages the free space in the data blocks by using free lists and a pair or storage parameters
PCTFREE and PCTUSED. When the block reaches the PCTUSED percentage the block is then
removed from the freelist, when the block falls below the PCTFREE threshold the block is then
Manual
placed back on the freelist. Oracle has to perform alot of hard work maintaining these lists, a slow
down in performance can occur when you are making lots of changes to the blocks as Oracle needs
to keep checking the block thresholds.
Oracle does not use freelist when using automatic mode, Instead oracle uses bitmaps. A bitmap which
is contained in a bitmap block, indicates whether free space in a data block is below 25%, between
25%-50%, between 50%-75% or above 75%. For an index block the bitmaps can tell you whether the
Automatic
blocks are empty or formatted. Bitmaps do use additional space but this is less than 1% for most
(default)
large objects.
The performance gain from using automatic segment management can be quite striking.
Tablespaces -3-
Permanent Tablespaces
• Small tablespace - The tablespace can be made up of a number of data files each of which can be quite
large in size
• Big tablespace - The tablespace will only be made up of one datafile and this can get extremely large.
Tablespace commands
DBA_TEMP_FILES
DBA_TABLESPACE_GROUPS
DBA_SEGEMENTS
DBA_FREE_SPACE
V$TABLESPACE
DATABASE_PROPERTIES Displat the default tablespace for the instance
Datafile Commands
If you create tablespaces with non-standard block sizes you must set the DB_nK_CACHE_SIZE parameter,
there are 5 non-stanardard sizes 2k, 4k, 8k, 16k and 32k. The DB_CACHE_SIZE parameter sets the default
block size for all new tablespace if the blocksize option is emitted.
Temporary tablespaces
Temporary tablespaces are used for order by, group by and create index. It is required when the system
tablespace is locally managed. In oracle 10g you can now create temporary tablespace groups which means you
can use multiple temporary tablespaces simultaneously.
When creating a temporary table, the table can exist only for the below
Undo Tablespaces
Undo tablespaces are used to store orginal data after it has been changed, if a user decides to rollback a change
the information in the undo tablespace is used to put back the data in its original state.
Creating create undo tablespace undotbs02 datafile ' c:\oracle\undo01.dbf' size 2G;
set default alter system set undo_tablespace='undotbs02';
Tablespace quotas
You can assign a user tablespace quota thus limiting to a certain amount of storage space within the tablespace.
By default a user has none when the account is first created.
Tablespace Alerts
The MMON daemon checks tablespace usage every 10 mins to see if any thresholds have been exceeded and
raises any alerts. There are two types of alerts warning (low space warning) and critical (action should be taken
immediately). Both thresholds can be changed via OEM or DBMS_SERVER_ALERT package.
Oracle can make file handling a lot easy by managing the oracle files itself, there are three parameters that can
be set so that oracle will manage the data, temp, redo, archive and flash logs for you
Tablespaces -6-
Tablespace Logging