SlideShare a Scribd company logo
Database Administrator
Lecture 10
Managing Tablespaces and Data
files
Objectives
 After completing this lesson, you should be able to do
the following:
 Describe the logical structure of the database
 Create tablespaces
 Change the size of tablespaces
 Allocate space for temporary segments
 Change the status of tablespaces
 Change the storage settings of tablespaces
 Implement Oracle Managed Files
Overview
Overview
 A small database might need only the SYSTEM tablespace
 Oracle recommends that you create additional tablespaces
to store user data, user indexes, undo segments, and
temporary segments separate from data dictionary
 The DBA can create new tablespaces, resize data files, add
data files to tablespaces
 Set and alter default segment storage settings for segments
created in a tablespace, make a tablespace read-only or
read-write, make a tablespace temporary or permanent, and
drop tablespaces
Database Storage Hierarchy
Database Architecture
 Oracle database architecture includes logical and physical
structures that make up the database
 The physical structure includes the control files, online redo
log files, and data files that make up the database
 The logical structure includes tablespaces, segments,
extents, and data blocks
 The Oracle server enables fine-grained control of disk space
use through tablespace and logical storage structures,
including segments, extents, and data blocks
Tablespaces
 The data in an Oracle database are stored in tablespaces
 An Oracle database can be logically grouped into smaller logical
areas of space known as tablespaces
 A tablespace can belong to only one database at a time
 Each tablespace consists of one or more operating system files,
which are called data files
 A tablespace may consist of zero or more segments
 Tablespaces can be brought online while the database is running
 Tablespaces can be switched between read-write and read-only
stat
Data Files
 Each tablespace in an Oracle database consists of one or
more files called data files. These are physical structures that
conform with the operating system on which the Oracle server
is running.
 A data file can belong to only one tablespace.
 An Oracle server creates a data file for a tablespace by
allocating the specified amount of disk space plus a small
amount of overhead.
 The database administrator can change the size of a data file
after its creation or can specify that a data file should
dynamically grow as objects in the tablespace grow
Segments
 A segment is the space allocated for a specific logical
storage structure within a tablespace. For example, all of the
storage allocated to a table is a segment.
 A tablespace may consist of one or more segments.
 A segment cannot span tablespaces; however, a segment
can span multiple data files that belong to the same
tablespace.
 Each segment is made up of one or more extents.
Extents
 Space is allocated to a segment by extents.
 One or more extents make up a segment.
 When a segment is created, it consists of at least one extent.
 As the segment grows, extents get added to the segment.
 The DBA can manually add extents to a segment.
 An extent is a set of contiguous Oracle blocks.
 An extent cannot span a data file but must exist in one data file
Data Blocks
 The Oracle server manages the storage space in the data files in
units called Oracle blocks or data blocks.
 The data in an Oracle database is stored in data blocks.
 Oracle data blocks are the smallest units of storage that the
Oracle server can allocate, read, or write.
 One data block corresponds to one or more operating system
blocks allocated from an existing data file.
 The standard data block size for an Oracle database is specified
by the DB_BLOCK_SIZE initialization parameter when the
database is created. The data block size should be a multiple of
the operating system block size to avoid unnecessary I/O.
 The maximum data block size is dependent on the operating
system
SYSTEM and Non-SYSTEM
Tablespaces
 SYSTEM tablespace:
 Created with the database
 Required in all databases
 Contains the data dictionary, including stored program units
 Contains the SYSTEM undo segment
 Should not contain user data, although it is allowed
 Non-SYSTEM tablespaces:
 Enable more flexibility in database administration
 Separate undo, temporary, application data, and application index
segments
 Separate data by backup requirements
 Separate dynamic and static data
 Control the amount of space allocated to user’s objects
Creating Tablespaces
 CREATE TABLESPACE tablespace
[DATAFILE clause]
[MINIMUM EXTENT integer[K|M]]
[BLOCKSIZE integer [K]]
[LOGGING|NOLOGGING]
[DEFAULT storage_clause ]
[ONLINE|OFFLINE]
[PERMANENT|TEMPORARY]
Creating Tablespaces
 where:
 tablespace is the name of the tablespace to be created
 DATAFILE specifies the data file or data files that make up the
tablespace
 MINIMUM EXTENT ensures that every used extent size in the
tablespace is a multiple of the integer. Use Kor M to specify this
size in kilobytes or megabytes.
 LOGGING specifies that, by default, all tables, indexes, and
partitions within the tablespace have all changes written to redo.
LOGGING is the default
Creating Tablespaces
 NOLOGGING specifies that, by default, all tables, indexes, and
partitions within the tablespace do not have all changes written to
redo. NOLOGGING affects only some DML and DDL commands, for
example, direct loads.
 DEFAULT specifies the default storage parameters for all objects
created in the tablespace creation
 OFFLINE makes the tablespace unavailable immediately after creation
 PERMANENT specifies that the tablespace can be used to hold
permanent objects
 TEMPORARY specifies that the tablespace be used only to hold
temporary objects; for example, segments used by implicit sorts
caused by an ORDER BY clause extent_management_clause
specifies how the extents of the tablespace are managed. This clause
is discussed in a subsequent section of this lesson
Creating Tablespaces
 CREATE TABLESPACE userdata
DATAFILE '/u01/oradata/userdata01.dbf' SIZE 100M
AUTOEXTEND ON NEXT 5M MAXSIZE 200M;
 where:
 filename is the name of a data file in the tablespace
 SIZE specifies the size of the file. Use K or M to specify the size
in kilobytes or megabytes.
 REUSE allows the Oracle server to reuse an existing file
 autoextend_clause enables or disables the automatic extension
of the data file.
Space Management in
Tablespaces
 Locally managed tablespaces:
 Free extents recorded in bitmap
 Each bit corresponds to a block or group of blocks
 Bit value indicates free or used
 Dictionary-managed tablespaces:
 Default method
 Free extents recorded in data dictionary tables
Advantages of Locally Managed
Tablespaces
 Local management avoids recursive space management operations, which
can occur in dictionary-managed tablespaces if consuming or releasing
space in an extent results in another operation that consumes or releases
space in a undo segment or data dictionary table.
 Because locally managed tablespaces do not record free space in data
dictionary tables, it reduces contention on these tables.
 Local management of extents automatically tracks adjacent free space,
eliminating the need to coalesce free extents.
 The sizes of extents that are managed locally can be determined
automatically by the system. Alternatively, all extents can have the same
size in a locally managed tablespace.
 Changes to the extent bitmaps do not generate undo information because
they do not update tables in the data dictionary
Locally Managed Tablespaces
 CREATE TABLESPACE userdata
DATAFILE '/u01/oradata/userdata01.dbf' SIZE 500M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K;
 The LOCAL option of the EXTENT MANAGEMENT clause
specifies that a tablespace is to be locally managed.
 By default a tablespace is locally managed
 extent_management_clause :==
[ EXTENT MANAGEMENT
[ DICTIONARY | LOCAL
[ AUTOALLOCATE | UNIFORM [SIZE integer[K|M]] ] ] ]
Dictionary Managed Tablespaces
 Extents are managed in the data dictionary
 Each segment stored in the tablespace can have a
different storage clause
 Merging required

More Related Content

Similar to tablespaces and datafiles in database administration (20)

PPT
Less07 storage
Amit Bhalla
 
PPT
Online Oracle Training For Beginners
vibrantuser
 
PPT
1650607.ppt
KalsoomTahir2
 
PPT
Presentation on tablespaceses segments extends and blocks
Vinay Ugave
 
PPTX
Big file tablespaces
dev3993
 
PPTX
12. oracle database architecture
Amrit Kaur
 
PPT
Oracle training-in-hyderabad
sreehari orienit
 
PDF
Tablespaces
Vinay Thota
 
PPT
Introduction to oracle
Madhavendra Dutt
 
PDF
ORACLE ARCHITECTURE
Manohar Tatwawadi
 
PPTX
Oracle Database Architecture
Hamzaakmak1
 
PPS
Oracle Database Overview
honglee71
 
PDF
MS-SQL SERVER ARCHITECTURE
Douglas Bernardini
 
PPT
Introduction to oracle(2)
Sumit Tambe
 
PPT
Introduction to oracle
Sumit Tambe
 
PPT
Less01 db architecture
Imran Ali
 
PPT
Oracle Architecture software overview ppts
ssuserf272701
 
PPT
Oracle Architecture
Neeraj Singh
 
Less07 storage
Amit Bhalla
 
Online Oracle Training For Beginners
vibrantuser
 
1650607.ppt
KalsoomTahir2
 
Presentation on tablespaceses segments extends and blocks
Vinay Ugave
 
Big file tablespaces
dev3993
 
12. oracle database architecture
Amrit Kaur
 
Oracle training-in-hyderabad
sreehari orienit
 
Tablespaces
Vinay Thota
 
Introduction to oracle
Madhavendra Dutt
 
ORACLE ARCHITECTURE
Manohar Tatwawadi
 
Oracle Database Architecture
Hamzaakmak1
 
Oracle Database Overview
honglee71
 
MS-SQL SERVER ARCHITECTURE
Douglas Bernardini
 
Introduction to oracle(2)
Sumit Tambe
 
Introduction to oracle
Sumit Tambe
 
Less01 db architecture
Imran Ali
 
Oracle Architecture software overview ppts
ssuserf272701
 
Oracle Architecture
Neeraj Singh
 

Recently uploaded (20)

PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Ad

tablespaces and datafiles in database administration

  • 3. Objectives  After completing this lesson, you should be able to do the following:  Describe the logical structure of the database  Create tablespaces  Change the size of tablespaces  Allocate space for temporary segments  Change the status of tablespaces  Change the storage settings of tablespaces  Implement Oracle Managed Files
  • 5. Overview  A small database might need only the SYSTEM tablespace  Oracle recommends that you create additional tablespaces to store user data, user indexes, undo segments, and temporary segments separate from data dictionary  The DBA can create new tablespaces, resize data files, add data files to tablespaces  Set and alter default segment storage settings for segments created in a tablespace, make a tablespace read-only or read-write, make a tablespace temporary or permanent, and drop tablespaces
  • 7. Database Architecture  Oracle database architecture includes logical and physical structures that make up the database  The physical structure includes the control files, online redo log files, and data files that make up the database  The logical structure includes tablespaces, segments, extents, and data blocks  The Oracle server enables fine-grained control of disk space use through tablespace and logical storage structures, including segments, extents, and data blocks
  • 8. Tablespaces  The data in an Oracle database are stored in tablespaces  An Oracle database can be logically grouped into smaller logical areas of space known as tablespaces  A tablespace can belong to only one database at a time  Each tablespace consists of one or more operating system files, which are called data files  A tablespace may consist of zero or more segments  Tablespaces can be brought online while the database is running  Tablespaces can be switched between read-write and read-only stat
  • 9. Data Files  Each tablespace in an Oracle database consists of one or more files called data files. These are physical structures that conform with the operating system on which the Oracle server is running.  A data file can belong to only one tablespace.  An Oracle server creates a data file for a tablespace by allocating the specified amount of disk space plus a small amount of overhead.  The database administrator can change the size of a data file after its creation or can specify that a data file should dynamically grow as objects in the tablespace grow
  • 10. Segments  A segment is the space allocated for a specific logical storage structure within a tablespace. For example, all of the storage allocated to a table is a segment.  A tablespace may consist of one or more segments.  A segment cannot span tablespaces; however, a segment can span multiple data files that belong to the same tablespace.  Each segment is made up of one or more extents.
  • 11. Extents  Space is allocated to a segment by extents.  One or more extents make up a segment.  When a segment is created, it consists of at least one extent.  As the segment grows, extents get added to the segment.  The DBA can manually add extents to a segment.  An extent is a set of contiguous Oracle blocks.  An extent cannot span a data file but must exist in one data file
  • 12. Data Blocks  The Oracle server manages the storage space in the data files in units called Oracle blocks or data blocks.  The data in an Oracle database is stored in data blocks.  Oracle data blocks are the smallest units of storage that the Oracle server can allocate, read, or write.  One data block corresponds to one or more operating system blocks allocated from an existing data file.  The standard data block size for an Oracle database is specified by the DB_BLOCK_SIZE initialization parameter when the database is created. The data block size should be a multiple of the operating system block size to avoid unnecessary I/O.  The maximum data block size is dependent on the operating system
  • 13. SYSTEM and Non-SYSTEM Tablespaces  SYSTEM tablespace:  Created with the database  Required in all databases  Contains the data dictionary, including stored program units  Contains the SYSTEM undo segment  Should not contain user data, although it is allowed  Non-SYSTEM tablespaces:  Enable more flexibility in database administration  Separate undo, temporary, application data, and application index segments  Separate data by backup requirements  Separate dynamic and static data  Control the amount of space allocated to user’s objects
  • 14. Creating Tablespaces  CREATE TABLESPACE tablespace [DATAFILE clause] [MINIMUM EXTENT integer[K|M]] [BLOCKSIZE integer [K]] [LOGGING|NOLOGGING] [DEFAULT storage_clause ] [ONLINE|OFFLINE] [PERMANENT|TEMPORARY]
  • 15. Creating Tablespaces  where:  tablespace is the name of the tablespace to be created  DATAFILE specifies the data file or data files that make up the tablespace  MINIMUM EXTENT ensures that every used extent size in the tablespace is a multiple of the integer. Use Kor M to specify this size in kilobytes or megabytes.  LOGGING specifies that, by default, all tables, indexes, and partitions within the tablespace have all changes written to redo. LOGGING is the default
  • 16. Creating Tablespaces  NOLOGGING specifies that, by default, all tables, indexes, and partitions within the tablespace do not have all changes written to redo. NOLOGGING affects only some DML and DDL commands, for example, direct loads.  DEFAULT specifies the default storage parameters for all objects created in the tablespace creation  OFFLINE makes the tablespace unavailable immediately after creation  PERMANENT specifies that the tablespace can be used to hold permanent objects  TEMPORARY specifies that the tablespace be used only to hold temporary objects; for example, segments used by implicit sorts caused by an ORDER BY clause extent_management_clause specifies how the extents of the tablespace are managed. This clause is discussed in a subsequent section of this lesson
  • 17. Creating Tablespaces  CREATE TABLESPACE userdata DATAFILE '/u01/oradata/userdata01.dbf' SIZE 100M AUTOEXTEND ON NEXT 5M MAXSIZE 200M;  where:  filename is the name of a data file in the tablespace  SIZE specifies the size of the file. Use K or M to specify the size in kilobytes or megabytes.  REUSE allows the Oracle server to reuse an existing file  autoextend_clause enables or disables the automatic extension of the data file.
  • 18. Space Management in Tablespaces  Locally managed tablespaces:  Free extents recorded in bitmap  Each bit corresponds to a block or group of blocks  Bit value indicates free or used  Dictionary-managed tablespaces:  Default method  Free extents recorded in data dictionary tables
  • 19. Advantages of Locally Managed Tablespaces  Local management avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a undo segment or data dictionary table.  Because locally managed tablespaces do not record free space in data dictionary tables, it reduces contention on these tables.  Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.  The sizes of extents that are managed locally can be determined automatically by the system. Alternatively, all extents can have the same size in a locally managed tablespace.  Changes to the extent bitmaps do not generate undo information because they do not update tables in the data dictionary
  • 20. Locally Managed Tablespaces  CREATE TABLESPACE userdata DATAFILE '/u01/oradata/userdata01.dbf' SIZE 500M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K;  The LOCAL option of the EXTENT MANAGEMENT clause specifies that a tablespace is to be locally managed.  By default a tablespace is locally managed  extent_management_clause :== [ EXTENT MANAGEMENT [ DICTIONARY | LOCAL [ AUTOALLOCATE | UNIFORM [SIZE integer[K|M]] ] ] ]
  • 21. Dictionary Managed Tablespaces  Extents are managed in the data dictionary  Each segment stored in the tablespace can have a different storage clause  Merging required