2080 4

BIT352 ยท 2080 ยท 5 marks

What are data files? How it is related with tablespace. Write a command to add a datafile in existing tablespace named "users".

What are data files? How it is related with tablespace. Write a command to add a datafile in existing tablespace named "users". [5]

Database Administration

Quick answer

Data files are the physical operating system files that actually store the data of an Oracle database on disk. Every piece of data stored in an Oracle database (tables, indexes, rollback segments, etc.) is ultimately written to one or more data files.

Data Files and Their Relationship with Tablespace

What are Data Files?

Key characteristics of data files:

  • They have a physical existence on the disk (e.g., .dbf files)
  • They store data in Oracle's internal block format
  • A single data file belongs to only one tablespace
  • They grow in size as more data is inserted into the database
  • They can be configured to auto-extend when full

Relationship Between Data Files and Tablespace

The relationship between data files and tablespaces is a logical-to-physical mapping:

Tablespace (Logical)Data File (Physical)
Logical storage unitPhysical storage unit
Groups related dataStores actual data on disk
One tablespace can have multiple data filesOne data file belongs to only one tablespace
  • A tablespace is a logical storage container in Oracle that groups related database objects (tables, indexes, etc.).
  • A data file is the physical file on the OS that backs the tablespace.
  • When a tablespace runs out of space, a new data file can be added to extend its capacity.

Diagram:

DATABASE
   |
   +-- TABLESPACE (Logical)
           |
           +-- Data File 1 (.dbf)  [Physical]
           |
           +-- Data File 2 (.dbf)  [Physical]

Command to Add a Data File to Existing Tablespace "USERS"

ALTER TABLESPACE users
ADD DATAFILE '/u01/oradata/orcl/users02.dbf'
SIZE 100M
AUTOEXTEND ON
NEXT 10M
MAXSIZE 500M;

Explanation of each clause:

ClauseDescription
ALTER TABLESPACE usersSpecifies the existing tablespace to modify
ADD DATAFILEAdds a new physical data file to the tablespace
'/u01/oradata/orcl/users02.dbf'Full path and name of the new data file
SIZE 100MInitial size of the data file (100 Megabytes)
AUTOEXTEND ONAllows the file to grow automatically when full
NEXT 10MExtends by 10 MB each time it auto-extends
MAXSIZE 500MMaximum size the file can grow to

Note: The path must be accessible by the Oracle database server process. On Windows, the path would be like 'C:\oradata\users02.dbf'.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.