0% found this document useful (0 votes)
40 views

Lab 4 - Tablespace & Datafile

A tablespace is a logical group of data files that store the physical data of database objects. A database contains at least one tablespace for storing data within datafiles. Tablespaces allow administrators to control disk space allocation, assign quotas, and perform backup/recovery operations. There are two types of tablespaces: default and temporary. Common tasks involve creating, altering, and dropping tablespaces and their associated datafiles.

Uploaded by

msskjc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Lab 4 - Tablespace & Datafile

A tablespace is a logical group of data files that store the physical data of database objects. A database contains at least one tablespace for storing data within datafiles. Tablespaces allow administrators to control disk space allocation, assign quotas, and perform backup/recovery operations. There are two types of tablespaces: default and temporary. Common tasks involve creating, altering, and dropping tablespaces and their associated datafiles.

Uploaded by

msskjc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Lab 4

Tablespace &
Datafile

IS221:
DATABASE MANAGEMENT SYSTEMS
Outline
Tablespace & Datafile
Create New Tablespace
Alter Tablespace
Manage Tablespace
Create Table in a Tablespace
Drop Tablespace

INFORMATION SYSTEMS DEPARTMENT 2


Tablespace & Datafile
Tablespace : is a logical group of data files in a database. A database
typically contains at least one tablespace, and usually two or more.
Within the database, the tablespace plays a role similar to that of a
folder on the hard drive of a computer.
Datafile : is a physical file of

the operating system that

store the data of all logical

structures in the database .

INFORMATION SYSTEMS DEPARTMENT 3


Tablespace
A database administrator can use tablespaces to :
 Control disk space allocation for database data
 Assign specific space quotas for database users
 Control availability of data by taking individual tablespace online or offline
(except the SYSTEM tablespace)
 Perform partial database backup or recovery operations

There are two types of tablespaces :


 Default tablespace
 Temporary tablespace

INFORMATION SYSTEMS DEPARTMENT 4


Check exist tablspaces
select tablespace_name ,status from dba_tablespaces;

INFORMATION SYSTEMS DEPARTMENT 5


Create New Tablespace
Create new tablespace:
“ create tablespace tablespace_name datafile ‘file_name’ size size ; “

INFORMATION SYSTEMS DEPARTMENT 6


Alter Tablespace
Adding a datafile:
“ alter tablespace tablespace_name add datafile ‘file_name’ size size ; ”

INFORMATION SYSTEMS DEPARTMENT 7


Alter Tablespace
Resize a datafile:
“ alter database datafile ‘ file_name ‘ resize new_size ; “

INFORMATION SYSTEMS DEPARTMENT 8


Alter Tablespace
Drop a datafile:
“ alter tablespace tablespace_name drop datafile ‘file_name’ ; “

INFORMATION SYSTEMS DEPARTMENT 9


Manage Tablespace
Make tablespace Read Only :
“ alter tablespace tablespace_name read only; “

 When try to alter the tablespace after make it read only, this message
will appear :

INFORMATION SYSTEMS DEPARTMENT 10


Manage Tablespace
Make tablespace read/ write:
“ alter tablespace tablespace_name read write; “

INFORMATION SYSTEMS DEPARTMENT 11


Create Table in a Tablespace
 To create table Client within the ts tablespace:

CREATE TABLE Client (


Client_id number(3) primary key,
name varchar2(8),
city varchar2(8))
TABLESPACE ts

INFORMATION SYSTEMS DEPARTMENT 12


Note
If you have the proper privileges and tablespace quota, you can
create a new table in any tablespace that is currently online.
Therefore, you should specify the TABLESPACE option in a
CREATE TABLE statement to identify the tablespace that will store
the new table.
If you do not specify a tablespace in a CREATE TABLE statement,
the table is created in your default tablespace

INFORMATION SYSTEMS DEPARTMENT 13


CHECK Table space
To find default permanent tablespace :
select username ,default_tablespace from dba_users where username =
‘YESRNAME';

Example

INFORMATION SYSTEMS DEPARTMENT 14


Change the user Default tablespace
alter user user_name default tablespace tablespace_name ;

INFORMATION SYSTEMS DEPARTMENT 15


Drop Tablespace
“ drop tablespace tablespace_name including contents and datafiles; “

INFORMATION SYSTEMS DEPARTMENT 16


Tablespace & Datafile
create tablespace tablespace_name datafile ‘file_name’ size 10m;

alter tablespace tablespace_name add datafile ‘file_name’ size 15m;

alter database datafile ‘file_name’ resize 20m;

alter tablespace tablespace_name drop datafile ‘file_name’ ;

alter tablespace tablespace_name read only;

alter tablespace tablespace_name read write;

drop tablespace tablespace_name including contents and datafiles;

INFORMATION SYSTEMS DEPARTMENT 17


INFORMATION SYSTEMS DEPARTMENT 18

You might also like