Professional Documents
Culture Documents
Tablespace MGMT in 10g PDF
Tablespace MGMT in 10g PDF
Tablespace MGMT in 10g PDF
Tablespaces
Segments
Extents
Blocks
Physically Oracle stores everything in file, called data files. Physical storage is
how Oracle stores the data physically in the system. Whereas logical storage
talks about how an end user actually accesses that data. The logical structures
are created and recognized by Oracle and are not known to the OS.
Tablespaces are divided into logical units of storage called SEGMENTS.
Segments are further divided into EXTENTS.
Extents are a collection of contiguous BLOCKS.
INTRODUCTION TO TABLESPACES
LOGICAL storage units called as tablespaces. It is a logical storage container for
segments. Segments are database objects, such as tables & indexes that
consume storage space.
A tablespace is a logical group of one or more data files in a database. It is logical
because a tablespace is not visible in the oracle file system. Oracle database can
contain multiple tablespaces, It can be ONLINE (accessible) or OFFLINE (not
accessible) whenever the database is open. The SYSTEM and
TEMPORARY
tablespaces can NOT be taken offline. Oracle database must have system &
sysaux tablespaces.
PERMANENT
TEMPORARY
UNDO
SYSTEM
SYSAUX
TEMP
UNDOTBS1
USERS
DICTIONARY MANAGED
Oracle use the data dictionary (tables in SYS schema) to track allocated and
free extents for tablespaces that is in " DICTIONARY MANAGED " mode.
Oracle updates the following tables in the data dictionary whenever an
extent is allocated, or freed for reuse.
Free space is recorded in the SYS.FET$ table.
Used space in the SYS.UET$ table.
CREATING DICTIONARY MANAGED TABLESPACE
EXTENT_MANAGEMENT
DICTIONARY
ORA - 12913
FILE#
BLOCK#
LENGTH
1279
EXT#
FILE#
BLOCK#
LENGTH SEGBLOCK#
12
10
STORAGE PARAMETERS
The storage parameters are NOT valid if extents that are managed locally.
NEXT, INITIAL, PCTINCREASE ,
MINEXTENTS, MAXEXTENTS, DEFAULT STORAGE
Min Extents
MIN_EXTENTS
1
40960
50
Eliminates the need for recursive SQL operations against the data dictionary
(UET$ & FET$ tables). Reduce contention on data dictionary tables. Locally
EXTENT_MAN
SYSTEM
DICTIONARY
SYSAUX
LOCAL
TEMP
LOCAL
USERS
DICTIONARY
SQL>execute dbms_space_admin.tablespace_migrate_from_local(XXXX);
SQL>exec dbms_space_admin.tablespace_migrate_to_local(TEST);
PL/SQL procedure successfully completed.
As I said , see the keyword "autoallocate" why extents are allocated with
different sizes as autoallocate specifies extent sizes are system generated. Most
likely our tablespace will be autoalloctate LMT.
Who wants to create extents with the same sizes, need to specify UNIFORM.
Lets start with two users . Each user is assigned different , different
tablespace. User ROSE is assigned to test tablespace(uniform). User SONA
is assigned to samp tablespace (autoallocate).
dba_tablespaces ;
LMT can use either autoallocate or uniform is all about allocation of new
next size for the extents starting with 64 KB. As the segments grow and more
extents are needed, Oracle starts allocating larger and larger sizes then it moves
to 1Mb , 8MB ultimately to 64Mb extents. We can make initial extent size of
greater than 64KB , it will allocate extents atleast the amount of the space.
UNIFORM
Create the extents the same size by specifying the size when create the
tablespace.
using
auto
allocateSpace
allocation
is
simplified,
because
MANAGING TABLESPACE
CREATE TABLESPACE
SYNTAX - CREATING A NEW TABLESPACE
ALTER TABLESPACE
SYNTAX - ADDING A NEW DATAFILE
DROP TABLESPACE
SYNTAX - DROP THE TABLESPACE
RENAMING DATAFILE
II) SYNTAX
SQL>alter database RENAME FILE old file path to 'newfile path;
SQL>alter database rename file /u01/app/test.dbf to /u01/test.dbf ;
Database altered.
CREATING DICTIONARY MANAGED TABLESPACE
SYNTAX
SQL>create tablespace <tsname> datafile 'file path ' size <size>m
extent management DICTIONARY;
SQL> create tablespace samp datafile '/u01/oradata/samp/samp01. dbf '
size 10m extent management dictionary ;
Tablespace created.
-- ENABLE LMT
ASSM takes total control of the parameters FREELISTS, FREELIST GROUPS, &
PCTUSED. Oracle will track and manage the used and free space in data blocks
MAXSIZE <size>m;
EXAMPLE - V
DEFAULT_TABLESPACE
SAN
USERS
SAM
SAMP
OFFLINE
RENAME
DROP
SYSTEM
NO
NO
NO
SYSAUX
YES
NO
NO
TEMPORARY
NO
YES
NO
UNDO
NO
YES
YES
SQL> select
DBMS_METADATA.GET_DDL('TABLESPACE', '
SQL> select
dual;
FIND DEFAULT_PERMANENT_TABLESPACE
PERMANENT TABLESPACE
Bigfile tablespaces are supported only for locally managed tablespaces with
automatic segment space management.
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
TEMPORARY TABLESPACES
CREATING LOCALLY MANAGED TEMPORARY TABLESPACE
ORA-12905
Here tmpts1 is created by oracle. If NO group exists oracle will create it.
TEMPORARY TABLESPACE WITH ASSOCIATED GROUP
V$SORT_SEGMENT
UNDO TABLESPACES
Undo tablespaces are used to store original data after it has been changed.
We can create more than one undo tablespace, but one of them can be
active at any one time. Oracle provides a fully automated mechanism, referred
to as automatic undo management, for managing undo information and space.
AUM (AUTOMATIC UNDO MANAGEMENT)
CREATING UNDO TABLESPACE
ORA-30013
SQL> drop tablespace UNDOTBS1 including contents and datafiles;
ERROR at line 1:
ORA-30013: undo tablespace ' UNDOTBS1 ' is currently in use
Only one undo tablespace can be active at a time. Here UNDOTBS1. We cannot
drop an undo tablespace if it is being used by any instance or if it contains any undo
data needed to roll back uncommitted transactions.
POINTS TO NOTE
so
undo_extent_stat.sql
DATABASE_PROPERTIES
The current settings for the default tablespaces can be viewed using the
DATABASE_PROPERTIES view.
VALUES
CONTENTS
STATUS
EXTENT_MANAGEMENT
DICTIONARY , LOCAL
ALLOCATION_TYPE
SEGMENT_SPACE_MANAGEMENT
MANUAL , AUTO