SlideShare a Scribd company logo
Copyright © Oracle Corporation, 2001. All rights reserved.
Managing Tablespaces and Datafiles
8-2 Copyright © Oracle Corporation, 2001. All rights reserved.
Objectives
After completing this lesson, you should be able to do
the following:
• Define the purpose of tablespaces and datafiles
• Create tablespaces
• Manage tablespaces
• Create and manage tablespaces using Oracle
Managed Files (OMF)
8-3 Copyright © Oracle Corporation, 2001. All rights reserved.
Tablespaces and Datafiles
Oracle stores data logically in tablespaces and
physically in datafiles.
• Tablespaces:
– Can belong to only one database at a time
– Consist of one or more datafiles
– Are further divided into logical units of storage
• Datafiles:
– Can belong to only one
tablespace and one database
– Are a repository for schema
object data
Database
Tablespace
Datafiles
8-4 Copyright © Oracle Corporation, 2001. All rights reserved.
Types of Tablespaces
• SYSTEM tablespace
– Created with the database
– Contains the data dictionary
– Contains the SYSTEM undo segment
• Non-SYSTEM tablespace
– Separate segments
– Eases space administration
– Controls amount of space allocated to a user
8-5 Copyright © Oracle Corporation, 2001. All rights reserved.
Creating Tablespaces
CREATE TABLESPACE userdata
DATAFILE '/u01/oradata/userdata01.dbf' SIZE 100M
AUTOEXTEND ON NEXT 5M MAXSIZE 200M;
A tablespace is created using the command:
CREATE TABLESPACE
8-9 Copyright © Oracle Corporation, 2001. All rights reserved.
Space Management in Tablespaces
• Locally managed tablespace:
– Free extents managed in the tablespace
– Bitmap is used to record free extents
– Each bit corresponds to a block or group of blocks
– Bit value indicates free or used
• Dictionary-managed tablespace:
– Free extents are managed by the data dictionary
– Appropriate tables are updated when extents are
allocated or deallocated
8-10 Copyright © Oracle Corporation, 2001. All rights reserved.
Locally Managed Tablespaces
• Reduced contention on data dictionary tables
• No undo generated when space allocation or
deallocation occurs
• No coalescing required
CREATE TABLESPACE userdata
DATAFILE '/u01/oradata/userdata01.dbf' SIZE 500M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;
8-12 Copyright © Oracle Corporation, 2001. All rights reserved.
Dictionary-Managed Tablespaces
• Extents are managed in the data dictionary
• Each segment stored in the tablespace can have a
different storage clause
• Coalescing required
CREATE TABLESPACE userdata
DATAFILE '/u01/oradata/userdata01.dbf'
SIZE 500M EXTENT MANAGEMENT DICTIONARY
DEFAULT STORAGE
(initial 1M NEXT 1M PCTINCREASE 0);
8-13 Copyright © Oracle Corporation, 2001. All rights reserved.
Undo Tablespace
• Used to store undo segments
• Cannot contain any other objects
• Extents are locally managed
• Can only use the DATAFILE and EXTENT
MANAGEMENT clauses
CREATE UNDO TABLESPACE undo1
DATAFILE '/u01/oradata/undo01.dbf' SIZE 40M;
8-14 Copyright © Oracle Corporation, 2001. All rights reserved.
Temporary Tablespaces
• Used for sort operations
• Cannot contain any permanent objects
• Locally managed extents recommended
CREATE TEMPORARY TABLESPACE temp
TEMPFILE '/u01/oradata/temp01.dbf' SIZE 500M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 4M;
8-17 Copyright © Oracle Corporation, 2001. All rights reserved.
Default Temporary Tablespace
• Specifies a database-wide default temporary
tablespace
• Eliminates using SYSTEM tablespace for storing
temporary data
• Can be created by using:
– CREATE DATABASE
– Locally managed
– ALTER DATABASE
ALTER DATABASE
DEFAULT TEMPORARY TABLESPACE temp;
8-18 Copyright © Oracle Corporation, 2001. All rights reserved.
Creating a Default Temporary Tablespace
• During database creation:
CREATE DATABASE DBA01
LOGFILE
GROUP 1 ('/$HOME/ORADATA/u01/redo01.log') SIZE 100M,
GROUP 2 ('/$HOME/ORADATA/u02/redo02.log') SIZE 100M,
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
DATAFILE '/$HOME/ORADATA/u01/system01.dbf' SIZE 325M
UNDO TABLESPACE undotbs
DATAFILE '/$HOME/ORADATA/u02/undotbs01.dbf' SIZE 200
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/$HOME/ORADATA/u03/temp01.dbf' SIZE 4M
CHARACTER SET US7ASCII
8-19 Copyright © Oracle Corporation, 2001. All rights reserved.
Creating a Default Temporary Tablespace
• After database creation:
• To find the default temporary tablespace for the
database query DATABASE_PROPERTIES
ALTER DATABASE
DEFAULT TEMPORARY TABLESPACE default_temp2;
SELECT * FROM DATABASE_PROPERTIES;
8-21 Copyright © Oracle Corporation, 2001. All rights reserved.
Restrictions on Default Temporary
Tablespace
Default temporary tablespaces cannot be:
• Dropped until after a new default is made available
• Taken offline
• Altered to a permanent tablespace
8-22 Copyright © Oracle Corporation, 2001. All rights reserved.
Read Only Tablespaces
• Use the following command to place a tablespace in
read only mode
– Causes a checkpoint
– Data available only for read operations
– Objects can be dropped from tablespace
ALTER TABLESPACE userdata READ ONLY;
8-25 Copyright © Oracle Corporation, 2001. All rights reserved.
Taking a Tablespace Offline
• Not available for data access
• Tablespaces that cannot be taken offline:
– SYSTEM tablespace
– Tablespaces with active undo segments
– Default temporary tablespace
• To take a tablespace offline:
• To bring a tablespace online:
ALTER TABLESPACE userdata OFFLINE;
ALTER TABLESPACE userdata ONLINE;
8-28 Copyright © Oracle Corporation, 2001. All rights reserved.
Changing Storage Settings
• Using ALTER TABLESPACE command to change
storage settings:
• Storage settings for locally managed tablespaces
cannot be altered.
ALTER TABLESPACE userdata MINIMUM EXTENT 2M;
ALTER TABLESPACE userdata
DEFAULT STORAGE (INITIAL 2M NEXT 2M
MAXEXTENTS 999);
8-30 Copyright © Oracle Corporation, 2001. All rights reserved.
Resizing a Tablespace
A tablespace can be resized by:
• Changing the size of a datafile:
– Automatically using AUTOEXTEND
– Manually using ALTER TABLESPACE
• Adding a datafile using ALTER TABLESPACE
8-31 Copyright © Oracle Corporation, 2001. All rights reserved.
Enabling Automatic Extension
of Datafiles
• Can be resized automatically with the following
commands:
– CREATE DATABASE
– CREATE TABLESPACE
– ALTER TABLESPACE … ADD DATAFILE
• Example:
• Query the DBA_DATA_FILES view to determine
whether AUTOEXTEND is enabled.
CREATE TABLESPACE user_data
DATAFILE
'/u01/oradata/userdata01.dbf' SIZE 200M
AUTOEXTEND ON NEXT 10M MAXSIZE 500M;
8-34 Copyright © Oracle Corporation, 2001. All rights reserved.
Manually Resizing a Datafile
• Manually increase or decrease a datafile size using
ALTER DATABASE
• Resizing a datafile adds more space without adding
more datafiles
• Manual resizing of a datafile reclaims unused space
in database
• Example:
ALTER DATABASE
DATAFILE '/u03/oradata/userdata02.dbf'
RESIZE 200M;
8-35 Copyright © Oracle Corporation, 2001. All rights reserved.
Adding Datafiles to a Tablespace
• Increases the space allocated to a tablespace by
adding additional datafiles
• ADD DATAFILE clause is used to add a datafile
• Example:
ALTER TABLESPACE user_data
ADD DATAFILE '/u01/oradata/userdata03.dbf'
SIZE 200M;
8-37 Copyright © Oracle Corporation, 2001. All rights reserved.
Methods for Moving Datafiles
• ALTER TABLESPACE
– Tablespace must be offline
– Target datafiles must exist
• Steps to rename a datafile:
– 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.
ALTER TABLESPACE userdata RENAME
DATAFILE '/u01/oradata/userdata01.dbf'
TO '/u02/oradata/userdata01.dbf';
8-38 Copyright © Oracle Corporation, 2001. All rights reserved.
Methods for Moving Datafiles
• ALTER DATABASE
– Database must be mounted
– Target datafile must exist
ALTER DATABASE RENAME
FILE '/u01/oradata/system01.dbf'
TO '/u03/oradata/system01.dbf';
8-40 Copyright © Oracle Corporation, 2001. All rights reserved.
Dropping Tablespaces
• Cannot drop a tablespace if it:
– Is the SYSTEM tablespace
– Has active segments
• INCLUDING CONTENTS drops the segments
• INCLUDING CONTENTS AND DATAFILES deletes
datafiles
• CASCADE CONSTRAINTS drops all referential
integrity constraints
DROP TABLESPACE userdata
INCLUDING CONTENTS AND DATAFILES;
8-43 Copyright © Oracle Corporation, 2001. All rights reserved.
Managing Tablespaces Using OMF
• Define the DB_CREATE_FILE_DEST parameter in one
of the following ways:
– Initialization parameter file
– Set dynamically using ALTER SYSTEM command
• When creating the tablespace:
– Datafile is automatically created and located in
DB_CREATE_FILE_DEST
– Default size is 100 MB
– AUTOEXTEND is set to UNLIMITED
ALTER SYSTEM SET
db_create_file_dest = '/u01/oradata/dba01';
8-44 Copyright © Oracle Corporation, 2001. All rights reserved.
Managing Tablespaces with OMF
• Creating an OMF tablespace:
• Adding an OMF datafile to an existing tablespace:
• Dynamically changing default file location:
• Dropping a tablespace includes deleting OS files:
CREATE TABLESPACE text_data DATAFILE SIZE 20M;
ALTER TABLESPACE text_data ADD DATAFILE;
ALTER SYSTEM SET
db_create_file_dest = '/u01/oradata/dba01';
8-45 Copyright © Oracle Corporation, 2001. All rights reserved.
Obtaining Tablespace Information
Obtaining tablespace and datafile information can be
obtained by querying the following:
• Tablespaces:
– DBA_TABLESPACES
– V$TABLESPACE
• Datafile information:
– DBA_DATA_FILES
– V$DATAFILE
• Temp file information:
– DBA_TEMP_FILES
– V$TEMPFILE
8-46 Copyright © Oracle Corporation, 2001. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Use tablespaces to separate data
• Create various types of tablespaces
• Manage tablespaces
• Manage tablespaces using OMF
8-47 Copyright © Oracle Corporation, 2001. All rights reserved.
Practice 8 Overview
This practice covers the following topics:
• Creating tablespaces
• Modifying tablespaces
• Configuring for and creating a tablespace using
OMF
8-48 Copyright © Oracle Corporation, 2001. All rights reserved.

More Related Content

PPT
database-stucture-and-space-managment.ppt
PPT
database-stucture-and-space-managment.ppt
PPTX
Big file tablespaces
PPT
Less05 storage
PPTX
An Introduction To Oracle Database
PPTX
Oracle DBA
PPTX
unit-ii.pptx
PPTX
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Big file tablespaces
Less05 storage
An Introduction To Oracle Database
Oracle DBA
unit-ii.pptx
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt

Similar to Week 10-11 Managing Tablespaces and Data Files.ppt (20)

PPT
Less02installation 100330034101-phpapp02
PPT
PPT
Overview of Primary Components of the Oracle
PPTX
Oracle DB installation using Oracle universal installer
PPT
Less01 db architecture
PPT
Les 11 fl2
PPT
Less02 installation
PPTX
tablespaces and datafiles in database administration
PPTX
Oracle administration classes in mumbai
PPT
Overview of Primary Components of the Oracle
PPTX
Sql server basics
PPT
Less07 storage
PPTX
Oracle architecture ppt
PDF
8 i locally_mgr_tbsp
PPT
Conceptos y herramientas del core de Oracle 11g
PPT
les_01_core_database-oracle00000000.ppt.ppt
PPT
D17316 gc20 l05_phys_sql
PPT
Oracle training-in-hyderabad
PPTX
Ibm db2
PPT
les_01_core.ppt
Less02installation 100330034101-phpapp02
Overview of Primary Components of the Oracle
Oracle DB installation using Oracle universal installer
Less01 db architecture
Les 11 fl2
Less02 installation
tablespaces and datafiles in database administration
Oracle administration classes in mumbai
Overview of Primary Components of the Oracle
Sql server basics
Less07 storage
Oracle architecture ppt
8 i locally_mgr_tbsp
Conceptos y herramientas del core de Oracle 11g
les_01_core_database-oracle00000000.ppt.ppt
D17316 gc20 l05_phys_sql
Oracle training-in-hyderabad
Ibm db2
les_01_core.ppt
Ad

More from IqraHanif27 (18)

PPT
personalitymaslow.ppt important notes and
PPTX
permissions.pptx computer science and tec
PDF
Lecture-02.pdf computer relationship easy
PDF
Lecture-01.pdf good lecture important notes
PPT
Quality Management.ppt in detail with notes
PPT
SPM.ppt details of spm project management
PPT
1588095888-intro.pptWeb Technologies and Tools (such as scripting tools) for ...
PPTX
link list.pptx complete notes detailed ans
PPTX
Lec10-Binary-Heaps-19122022-113509am.pptx
PPTX
Lec5-Doubly-Linked-List-24102022-110112am.pptx
PPTX
Lec12-Hash-Tables-27122022-125641pm.pptx
PPTX
NevigationMenu.pptx complete notes and types
PPTX
Chapter 3.pptx multimedia and conquer the same thing
PPTX
Chapter 2.pptx multimedia and the uses inlife
PPTX
Chapter 1.pptx multimedia and its uses in
PPTX
economics.pptx gross domastic product uses
PDF
Intro_Chapter_03B.pdf types of printers with example
PPT
ch1.ppt operating system from computer science for BSCs
personalitymaslow.ppt important notes and
permissions.pptx computer science and tec
Lecture-02.pdf computer relationship easy
Lecture-01.pdf good lecture important notes
Quality Management.ppt in detail with notes
SPM.ppt details of spm project management
1588095888-intro.pptWeb Technologies and Tools (such as scripting tools) for ...
link list.pptx complete notes detailed ans
Lec10-Binary-Heaps-19122022-113509am.pptx
Lec5-Doubly-Linked-List-24102022-110112am.pptx
Lec12-Hash-Tables-27122022-125641pm.pptx
NevigationMenu.pptx complete notes and types
Chapter 3.pptx multimedia and conquer the same thing
Chapter 2.pptx multimedia and the uses inlife
Chapter 1.pptx multimedia and its uses in
economics.pptx gross domastic product uses
Intro_Chapter_03B.pdf types of printers with example
ch1.ppt operating system from computer science for BSCs
Ad

Recently uploaded (20)

PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
System and Network Administraation Chapter 3
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Transform Your Business with a Software ERP System
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Introduction to Artificial Intelligence
PDF
Nekopoi APK 2025 free lastest update
Softaken Excel to vCard Converter Software.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
How Creative Agencies Leverage Project Management Software.pdf
Understanding Forklifts - TECH EHS Solution
CHAPTER 2 - PM Management and IT Context
wealthsignaloriginal-com-DS-text-... (1).pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
System and Network Administraation Chapter 3
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Upgrade and Innovation Strategies for SAP ERP Customers
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Reimagine Home Health with the Power of Agentic AI​
Transform Your Business with a Software ERP System
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
Essential Infomation Tech presentation.pptx
Introduction to Artificial Intelligence
Nekopoi APK 2025 free lastest update

Week 10-11 Managing Tablespaces and Data Files.ppt

  • 1. Copyright © Oracle Corporation, 2001. All rights reserved. Managing Tablespaces and Datafiles
  • 2. 8-2 Copyright © Oracle Corporation, 2001. All rights reserved. Objectives After completing this lesson, you should be able to do the following: • Define the purpose of tablespaces and datafiles • Create tablespaces • Manage tablespaces • Create and manage tablespaces using Oracle Managed Files (OMF)
  • 3. 8-3 Copyright © Oracle Corporation, 2001. All rights reserved. Tablespaces and Datafiles Oracle stores data logically in tablespaces and physically in datafiles. • Tablespaces: – Can belong to only one database at a time – Consist of one or more datafiles – Are further divided into logical units of storage • Datafiles: – Can belong to only one tablespace and one database – Are a repository for schema object data Database Tablespace Datafiles
  • 4. 8-4 Copyright © Oracle Corporation, 2001. All rights reserved. Types of Tablespaces • SYSTEM tablespace – Created with the database – Contains the data dictionary – Contains the SYSTEM undo segment • Non-SYSTEM tablespace – Separate segments – Eases space administration – Controls amount of space allocated to a user
  • 5. 8-5 Copyright © Oracle Corporation, 2001. All rights reserved. Creating Tablespaces CREATE TABLESPACE userdata DATAFILE '/u01/oradata/userdata01.dbf' SIZE 100M AUTOEXTEND ON NEXT 5M MAXSIZE 200M; A tablespace is created using the command: CREATE TABLESPACE
  • 6. 8-9 Copyright © Oracle Corporation, 2001. All rights reserved. Space Management in Tablespaces • Locally managed tablespace: – Free extents managed in the tablespace – Bitmap is used to record free extents – Each bit corresponds to a block or group of blocks – Bit value indicates free or used • Dictionary-managed tablespace: – Free extents are managed by the data dictionary – Appropriate tables are updated when extents are allocated or deallocated
  • 7. 8-10 Copyright © Oracle Corporation, 2001. All rights reserved. Locally Managed Tablespaces • Reduced contention on data dictionary tables • No undo generated when space allocation or deallocation occurs • No coalescing required CREATE TABLESPACE userdata DATAFILE '/u01/oradata/userdata01.dbf' SIZE 500M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;
  • 8. 8-12 Copyright © Oracle Corporation, 2001. All rights reserved. Dictionary-Managed Tablespaces • Extents are managed in the data dictionary • Each segment stored in the tablespace can have a different storage clause • Coalescing required CREATE TABLESPACE userdata DATAFILE '/u01/oradata/userdata01.dbf' SIZE 500M EXTENT MANAGEMENT DICTIONARY DEFAULT STORAGE (initial 1M NEXT 1M PCTINCREASE 0);
  • 9. 8-13 Copyright © Oracle Corporation, 2001. All rights reserved. Undo Tablespace • Used to store undo segments • Cannot contain any other objects • Extents are locally managed • Can only use the DATAFILE and EXTENT MANAGEMENT clauses CREATE UNDO TABLESPACE undo1 DATAFILE '/u01/oradata/undo01.dbf' SIZE 40M;
  • 10. 8-14 Copyright © Oracle Corporation, 2001. All rights reserved. Temporary Tablespaces • Used for sort operations • Cannot contain any permanent objects • Locally managed extents recommended CREATE TEMPORARY TABLESPACE temp TEMPFILE '/u01/oradata/temp01.dbf' SIZE 500M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 4M;
  • 11. 8-17 Copyright © Oracle Corporation, 2001. All rights reserved. Default Temporary Tablespace • Specifies a database-wide default temporary tablespace • Eliminates using SYSTEM tablespace for storing temporary data • Can be created by using: – CREATE DATABASE – Locally managed – ALTER DATABASE ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;
  • 12. 8-18 Copyright © Oracle Corporation, 2001. All rights reserved. Creating a Default Temporary Tablespace • During database creation: CREATE DATABASE DBA01 LOGFILE GROUP 1 ('/$HOME/ORADATA/u01/redo01.log') SIZE 100M, GROUP 2 ('/$HOME/ORADATA/u02/redo02.log') SIZE 100M, MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 DATAFILE '/$HOME/ORADATA/u01/system01.dbf' SIZE 325M UNDO TABLESPACE undotbs DATAFILE '/$HOME/ORADATA/u02/undotbs01.dbf' SIZE 200 DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/$HOME/ORADATA/u03/temp01.dbf' SIZE 4M CHARACTER SET US7ASCII
  • 13. 8-19 Copyright © Oracle Corporation, 2001. All rights reserved. Creating a Default Temporary Tablespace • After database creation: • To find the default temporary tablespace for the database query DATABASE_PROPERTIES ALTER DATABASE DEFAULT TEMPORARY TABLESPACE default_temp2; SELECT * FROM DATABASE_PROPERTIES;
  • 14. 8-21 Copyright © Oracle Corporation, 2001. All rights reserved. Restrictions on Default Temporary Tablespace Default temporary tablespaces cannot be: • Dropped until after a new default is made available • Taken offline • Altered to a permanent tablespace
  • 15. 8-22 Copyright © Oracle Corporation, 2001. All rights reserved. Read Only Tablespaces • Use the following command to place a tablespace in read only mode – Causes a checkpoint – Data available only for read operations – Objects can be dropped from tablespace ALTER TABLESPACE userdata READ ONLY;
  • 16. 8-25 Copyright © Oracle Corporation, 2001. All rights reserved. Taking a Tablespace Offline • Not available for data access • Tablespaces that cannot be taken offline: – SYSTEM tablespace – Tablespaces with active undo segments – Default temporary tablespace • To take a tablespace offline: • To bring a tablespace online: ALTER TABLESPACE userdata OFFLINE; ALTER TABLESPACE userdata ONLINE;
  • 17. 8-28 Copyright © Oracle Corporation, 2001. All rights reserved. Changing Storage Settings • Using ALTER TABLESPACE command to change storage settings: • Storage settings for locally managed tablespaces cannot be altered. ALTER TABLESPACE userdata MINIMUM EXTENT 2M; ALTER TABLESPACE userdata DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 999);
  • 18. 8-30 Copyright © Oracle Corporation, 2001. All rights reserved. Resizing a Tablespace A tablespace can be resized by: • Changing the size of a datafile: – Automatically using AUTOEXTEND – Manually using ALTER TABLESPACE • Adding a datafile using ALTER TABLESPACE
  • 19. 8-31 Copyright © Oracle Corporation, 2001. All rights reserved. Enabling Automatic Extension of Datafiles • Can be resized automatically with the following commands: – CREATE DATABASE – CREATE TABLESPACE – ALTER TABLESPACE … ADD DATAFILE • Example: • Query the DBA_DATA_FILES view to determine whether AUTOEXTEND is enabled. CREATE TABLESPACE user_data DATAFILE '/u01/oradata/userdata01.dbf' SIZE 200M AUTOEXTEND ON NEXT 10M MAXSIZE 500M;
  • 20. 8-34 Copyright © Oracle Corporation, 2001. All rights reserved. Manually Resizing a Datafile • Manually increase or decrease a datafile size using ALTER DATABASE • Resizing a datafile adds more space without adding more datafiles • Manual resizing of a datafile reclaims unused space in database • Example: ALTER DATABASE DATAFILE '/u03/oradata/userdata02.dbf' RESIZE 200M;
  • 21. 8-35 Copyright © Oracle Corporation, 2001. All rights reserved. Adding Datafiles to a Tablespace • Increases the space allocated to a tablespace by adding additional datafiles • ADD DATAFILE clause is used to add a datafile • Example: ALTER TABLESPACE user_data ADD DATAFILE '/u01/oradata/userdata03.dbf' SIZE 200M;
  • 22. 8-37 Copyright © Oracle Corporation, 2001. All rights reserved. Methods for Moving Datafiles • ALTER TABLESPACE – Tablespace must be offline – Target datafiles must exist • Steps to rename a datafile: – 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. ALTER TABLESPACE userdata RENAME DATAFILE '/u01/oradata/userdata01.dbf' TO '/u02/oradata/userdata01.dbf';
  • 23. 8-38 Copyright © Oracle Corporation, 2001. All rights reserved. Methods for Moving Datafiles • ALTER DATABASE – Database must be mounted – Target datafile must exist ALTER DATABASE RENAME FILE '/u01/oradata/system01.dbf' TO '/u03/oradata/system01.dbf';
  • 24. 8-40 Copyright © Oracle Corporation, 2001. All rights reserved. Dropping Tablespaces • Cannot drop a tablespace if it: – Is the SYSTEM tablespace – Has active segments • INCLUDING CONTENTS drops the segments • INCLUDING CONTENTS AND DATAFILES deletes datafiles • CASCADE CONSTRAINTS drops all referential integrity constraints DROP TABLESPACE userdata INCLUDING CONTENTS AND DATAFILES;
  • 25. 8-43 Copyright © Oracle Corporation, 2001. All rights reserved. Managing Tablespaces Using OMF • Define the DB_CREATE_FILE_DEST parameter in one of the following ways: – Initialization parameter file – Set dynamically using ALTER SYSTEM command • When creating the tablespace: – Datafile is automatically created and located in DB_CREATE_FILE_DEST – Default size is 100 MB – AUTOEXTEND is set to UNLIMITED ALTER SYSTEM SET db_create_file_dest = '/u01/oradata/dba01';
  • 26. 8-44 Copyright © Oracle Corporation, 2001. All rights reserved. Managing Tablespaces with OMF • Creating an OMF tablespace: • Adding an OMF datafile to an existing tablespace: • Dynamically changing default file location: • Dropping a tablespace includes deleting OS files: CREATE TABLESPACE text_data DATAFILE SIZE 20M; ALTER TABLESPACE text_data ADD DATAFILE; ALTER SYSTEM SET db_create_file_dest = '/u01/oradata/dba01';
  • 27. 8-45 Copyright © Oracle Corporation, 2001. All rights reserved. Obtaining Tablespace Information Obtaining tablespace and datafile information can be obtained by querying the following: • Tablespaces: – DBA_TABLESPACES – V$TABLESPACE • Datafile information: – DBA_DATA_FILES – V$DATAFILE • Temp file information: – DBA_TEMP_FILES – V$TEMPFILE
  • 28. 8-46 Copyright © Oracle Corporation, 2001. All rights reserved. Summary In this lesson, you should have learned how to: • Use tablespaces to separate data • Create various types of tablespaces • Manage tablespaces • Manage tablespaces using OMF
  • 29. 8-47 Copyright © Oracle Corporation, 2001. All rights reserved. Practice 8 Overview This practice covers the following topics: • Creating tablespaces • Modifying tablespaces • Configuring for and creating a tablespace using OMF
  • 30. 8-48 Copyright © Oracle Corporation, 2001. All rights reserved.