Professional Documents
Culture Documents
(8i Default) NO NO
Local Auto
Plugged In Logging
(9i Default)
Create
Mode
Status
Permanent Offline
DBA_TABLESPACES
DBA_DATA_FILES Temporary
Undo
DBA_FREE_SPACE
DBA_TEMP_FILES
• Dictates how the physical space of a database is Oracle stores data logically in tablespaces and
used physically in datafiles.
• Hierarchy consisting of tablespaces, segments, • Tablespaces:
extents, and blocks – Can belong to only one database at a time
– Consist of one or more datafiles
Tablespace – Are further divided into logical units of storage
Datafile • Datafiles:
Segment Database
Segment – Can belong to only one
tablespace and one database Tablespace
– Are a repository for schema
object data
Datafiles
Extent Blocks
Day - 2
Page 1
Types of Tablespaces Creating Tablespaces
Day - 2 Page 2
Dictionary-Managed Tablespaces Creating a Default Temporary Tablespace
Default temporary tablespaces cannot be: • Use the following command to place a tablespace in
• Dropped until after a new default is made available read only mode
• Taken offline ALTER TABLESPACE userdata READ ONLY;
– Causes a checkpoint
– Data available only for read operations
– Objects can be dropped from tablespace
Day - 2 Page 3
Taking a Tablespace Offline Changing Storage Settings
• Not available for data access • Using ALTER TABLESPACE command to change
• Tablespaces that cannot be taken offline: storage settings:
– SYSTEM tablespace ALTER TABLESPACE userdata MINIMUM EXTENT 2M;
– Tablespaces with active undo segments
– Default temporary tablespace ALTER TABLESPACE userdata
DEFAULT STORAGE (INITIAL 2M NEXT 2M
• To take a tablespace offline: MAXEXTENTS 999);
ALTER TABLESPACE userdata OFFLINE;
• Manually increase or decrease a datafile size using • Increases the space allocated to a tablespace by
ALTER DATABASE adding additional datafiles
• Resizing a datafile adds more space without adding • ADD DATAFILE clause is used to add a datafile
more datafiles • Example:
• Manual resizing of a datafile reclaims unused space
in database ALTER TABLESPACE user_data
ADD DATAFILE '/u01/oradata/userdata03.dbf'
• Example: SIZE 200M;
ALTER DATABASE
DATAFILE '/u03/oradata/userdata02.dbf'
RESIZE 200M;
• ALTER TABLESPACE
• ALTER DATABASE
– Tablespace must be offline
– Database must be mounted
– Target datafiles must exist
– Target datafile must exist
ALTER TABLESPACE userdata RENAME
DATAFILE '/u01/oradata/userdata01.dbf' ALTER DATABASE RENAME
TO '/u02/oradata/userdata01.dbf'; FILE '/u01/oradata/system01.dbf'
• Steps to rename a datafile: TO '/u03/oradata/system01.dbf';
– Take the tablespace offline.
– Use an OS command to move or copy the files.
– Execute the ALTER TABLESPACE RENAME DATAFILE
command.
– Bring the tablespace online.
– Use an OS command to delete the file if necessary.
Page 5
Day - 2
Dropping Tablespaces Obtaining Tablespace Information
• Cannot drop a tablespace if it: Obtaining tablespace and datafile information can be
– Is the SYSTEM tablespace obtained by querying the following:
• INCLUDING CONTENTS drops the segments • Tablespaces:
• INCLUDING CONTENTS AND DATAFILES deletes – DBA_TABLESPACES
datafiles – V$TABLESPACE
• Datafile information:
– DBA_DATA_FILES
– V$DATAFILE
Database
PROD
TABLESPACES
SYSTEM USER_DATA RBS TEMP
DATAFILES
Storage Structure and Relationships DISK2/
DISK1/SYS1.dbf USER1.dbf
DISK3/ DISK1/ DISK1/
USER2.dbf ROLL1.dbf TEMP.dbf
SEGMENTS S_DEP T S_E MP S _DE P T S _EM P RBS1 RBS2 RBS1 RBS2
Temp
(c ont 'd) FI RST _N (c ont 'd) (c ont 'd)
D.D. D.D. AME
In dex
Table Index RB RB RB RB
RB Data Data Data S eg S eg S eg S eg Temp
Data Index S eg
I ndex
Seg Seg Seg S eg Seg
Seg Seg
EXTENTS
1 2 1 2 1 2 1 1 2 2 1 FREE 1 1 2 2 1
Day - 2 Page 6
Types of Segments Types of Segments
Index-organized Index
table partition
Table Table
partition
Undo Temporary
Cluster Index segment segment
Oracle default
Tablespace
Segment
Bootstrap
segment
Day - 2 Page 7
Extent Allocation and Deallocation Used and Free Extents
Data file
• An extent is a chunk of space used by a segment
within a tablespace.
• An extent is allocated when the segment is:
– Created
• An extent is deallocated when the segment is:
– Dropped
– Truncated
Day - 2 Page 8
Standard Block Size Nonstandard Block Size
• Set at database creation using the DB_BLOCK_SIZE • Configure additional caches with the following
parameter; cannot be changed without re-creating dynamic parameters:
the database – DB_2K_CACHE_SIZE for 2 KB blocks
– DB_4K_CACHE_SIZE for 4 KB blocks
• DB_CACHE_SIZE specifies the size of the DEFAULT – DB_8K_CACHE_SIZE for 8 KB blocks
buffer cache for standard block size: – DB_16K_CACHE_SIZE for 16 KB blocks
– DB_32K_CACHE_SIZE for 32 KB blocks
Free space
Data
Day - 2 Page 9
Block Space Data Block Management
Utilization Parameters
PCTFREE
PCTUSED
• It is a method of managing free space inside • Bitmap segments contain a bitmap that describes
database segments. the status of each block in the segment with respect
• Tracking in-segment free and used space is done to its available space.
using bitmaps as opposed to using free lists. • The map is contained in a separate set of blocks
• This method provides: referred to as bitmapped blocks (BMBs).
– Ease of management • When inserting a new row, the server searches the
– Better space utilization map for a block with sufficient space.
– Better performance for concurrent INSERT operations • As the amount of space available in a block
changes, its new state is reflected in the bitmap.
Day - 2 Page 10
Configuring Automatic Segment-Space Manual Data Block Management
Management
• Automatic segment-space management can be • Allows you to configure data blocks manually using
enabled at the tablespace level only, for locally parameters such as:
managed tablespaces. – PCTFREE
CREATE TABLESPACE data02 – PCTUSED
DATAFILE ‘/u01/oradata/data02.dbf’ SIZE 5M – FREELIST
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64K • Only method available in previous Oracle versions
SEGMENT SPACE MANAGEMENT AUTO;
Day - 2 Page 11