Database Administration ยท Unit 4
Tablespace and Storage Management
Exam-focused notes for Tablespace and Storage Management (Database Administration, BIT352): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
Tablespace and Storage Management in short
This chapter covers how Oracle stores data in tablespaces and datafiles, how undo works, and how space is used inside blocks. Good storage management keeps the database from running out of space.
What this unit covers
- Tablespace concepts and types
- Datafile management and creation
- Adding new tablespaces and datafiles
- UNDO tablespace and UNDO RETENTION policy
- Viewing and altering UNDO RETENTION
- Space management and segment creation
- Extent and row chaining concepts
- Row migration in storage
Space management and segment creation
2081 ยท 10 marks
What is space management? How space management is done? How can you create tables without segments?[10]
Adding new tablespaces and datafiles
2081 ยท 5 marks
What is tablespace and datafile in oracle? How can we add new tablespace and datafiles in oracle database? [5]
Show solved answerHide answer
Tablespace and Datafile in Oracle
Tablespace
A tablespace is a logical storage unit in an Oracle database that groups related logical structures (tables, indexes, etc.) together. It is the bridge between the physical and logical components of an Oracle database. Every Oracle database has at least one tablespace called the SYSTEM tablespace.
Key points:
- It is a logical storage container
- A database is divided into one or more tablespaces
- Each tablespace belongs to only one database
Datafile
A datafile is a physical operating system file that actually stores the data on disk. Every tablespace is made up of one or more datafiles.
Key points:
- It is a physical file stored on the disk (e.g.,
.dbffile) - One tablespace can have multiple datafiles
- One datafile belongs to only one tablespace
Relationship:
Database --> Tablespace (Logical) --> Datafile (Physical)
Adding a New Tablespace
Use the CREATE TABLESPACE statement:
CREATE TABLESPACE my_tablespace
DATAFILE '/u01/oradata/mydb/my_tablespace01.dbf'
SIZE 100M
AUTOEXTEND ON
NEXT 10M
MAXSIZE 500M;
Explanation of clauses:
| Clause | Meaning |
|---|---|
DATAFILE | Specifies the physical file path and name |
SIZE | Initial size of the datafile |
AUTOEXTEND ON | Automatically extends when full |
NEXT | Size by which file extends each time |
MAXSIZE | Maximum size the file can grow to |
Adding a New Datafile to an Existing Tablespace
Use the ALTER TABLESPACE statement:
ALTER TABLESPACE my_tablespace
ADD DATAFILE '/u01/oradata/mydb/my_tablespace02.dbf'
SIZE 50M
AUTOEXTEND ON
NEXT 5M
MAXSIZE 200M;
This adds a second datafile to the existing tablespace my_tablespace, increasing its total storage capacity.
Summary
| Concept | Type | Description |
|---|---|---|
| Tablespace | Logical | Groups database objects logically |
| Datafile | Physical | Actual file on disk storing data |
CREATE TABLESPACE | DDL | Creates a new tablespace with datafile |
ALTER TABLESPACE ... ADD DATAFILE | DDL | Adds a new datafile to existing tablespace |
0 ยท 5 marks
What is tablespace and datafile in oracle? How we can add new tablespace and datafiles in oracle database? [5]
Show solved answerHide answer
Tablespace and Datafile in Oracle
Tablespace
A tablespace is the logical storage unit in an Oracle database. It is a logical grouping of one or more datafiles that stores database objects such as tables, indexes, and other schema objects. Every Oracle database has at least one tablespace called the SYSTEM tablespace.
Key points:
- Tablespace is a logical concept
- It acts as a bridge between the physical storage (datafiles) and the logical database objects
- Common tablespaces:
SYSTEM,SYSAUX,USERS,TEMP,UNDOTBS
Datafile
A datafile is the physical file stored on disk that corresponds to a tablespace. Each tablespace consists of one or more datafiles, but a datafile can belong to only one tablespace.
Key points:
- Datafile is a physical concept (actual
.dbffile on OS) - It stores the actual data of database objects
- Its size can be fixed or set to auto-extend
Relationship
Database
โโโ Tablespace (Logical)
โโโ Datafile(s) (Physical - .dbf files on disk)
Adding a New Tablespace in Oracle
Use the CREATE TABLESPACE statement:
CREATE TABLESPACE my_tablespace
DATAFILE '/u01/oradata/mydb/my_tablespace01.dbf'
SIZE 100M
AUTOEXTEND ON
NEXT 10M
MAXSIZE 500M;
Explanation of clauses:
| Clause | Meaning |
|---|---|
DATAFILE | Specifies the physical file path and name |
SIZE | Initial size of the datafile |
AUTOEXTEND ON | Allows the file to grow automatically |
NEXT | Size by which the file grows each time |
MAXSIZE | Maximum size the file can reach |
Adding a New Datafile to an Existing Tablespace
Use the ALTER TABLESPACE statement:
ALTER TABLESPACE my_tablespace
ADD DATAFILE '/u01/oradata/mydb/my_tablespace02.dbf'
SIZE 50M
AUTOEXTEND ON
NEXT 5M
MAXSIZE 200M;
This adds a second datafile to the existing my_tablespace, increasing its total storage capacity.
Summary
| Feature | Tablespace | Datafile |
|---|---|---|
| Nature | Logical | Physical |
| Location | Oracle metadata | OS file system |
| Relationship | Contains datafiles | Belongs to one tablespace |
| Command | CREATE TABLESPACE | ALTER TABLESPACE ... ADD DATAFILE |
UNDO tablespace and UNDO RETENTION policy
2081.1 ยท 10 marks
What is Tablespace? What is UNDO RETENTION Policy? Write different commands to manage the tablespaces in Oracle.[10]
0 ยท 5 marks
What is UNDO tablespace and UNDO RETENTION policy? How to view and alter UNDO RETENTION Policy in oracle. [5]
Extent and row chaining concepts
2081.1 ยท 5 marks
What is Extent? Explain Row chaining and Migration in brief. [5]
Make Unit 4 stick
Practice BIT352 with flashcards & quizzes