You are on page 1of 5

Satya Narayana Reddy

Surendra Reddy
9966990878

Tablespace:
i).It is logical storage unit in Oracle Database.
ii) Tablespace consist of one or more datafiles (check below)
iii) Information about Tablespace can be obtained from view DBA_TABLESPACES,
USER_TABLESPACES, DBA_TEMP_FILES (for Temporary Tablespaces)
iv) Tablespace is further divided in to logical units Segments (Segment is divided in to Extent
and Extent in to Block). To know more about Segment, Extents and Blocks
v) Various type of Tablespace are BIGFILE, SYSTEM, SYSAUX, UNDO and TEMPORARY.
1).How to create Tablespace?
SQL>create tablespace xcell11 datafile '/d01/oracle/oradata/gen/xcell11.dbf' size 50m autoextend
on next 5m maxsize 100m offline nologging
2).How to create a Temporary Tablespace?
SQL>create temporary tablespace xcell21 tempfile '/d01/oracle/oradata/gen/temp.dbf' size 5m
autoextend on;
3).How to create undo tablespace?
SQl>create undo tablespace xcell12 datafile '/d01/oracle/oradata/gen/undo.dbf' size 5m autoextend
on retention guarantee;
4) How to create Bigfile tablespace?
SQL>create bigfile tablespace big datafile '/d01/oracle/oradata/gen/big.dbf' size 50m autoextend on;
5).How to take offline a tablespace?
SQL>alter tablespace tablespace_name offline (normal, immediate, temporary)
6).How to take online a tablespace?
SQL>altert tablespace tablespace_name online;
7) How to rename a tablespace?
SQL>alter tablespace xcell11 rename to xcell2l;
8) How to make a tablespace read only?
SQL>alter tablespace xcell2l read only;
Xcell-it Solutions, Ayyappa Society, Madhapur, Hyderabad. Contact:-9985296674, 040-64566226, 40202040

Satya Narayana Reddy

Surendra Reddy
9966990878

9) How to make a tablespace read write?


SQl> alter tablespace xcell2l read write;
10).How to create a temporary tablespace group?
SQL> create temporary tablespace xcell tempfile '/d01/oracle/oradata/gen/ddd.dbf' size 5m
tablespace group xcell;
11).How to add a tablespace to existing group?
SQL> alter tablespace xcell21 tablespace group xcell;
12).How to remove a tablespace from a group?
SQL> alter tablespace xcell21 tablespace group ;
13).How to assigning a tablespace group as the default temporary tablespace?
SQL>alter database default temporary tablespace xcellsds;
14).How to assigning a default temporary tablespace to database?
SQL> alter database default temporary tablespace xcell21;
15).How to drop a tablespace?
SQL>drop tablespace tablespace_name;
16).How to drop tablespace and datafiles?
SQL>drop tablespace tablespace_name including contents and datafiles;
17) For more information you can query these views.
a) DBA_TABLESPACES, USER_TABLESPACES,
b) Dba_tablespace_groups, V$ENCRYPTED_TABLESPACES;
c) v$tablespace
d) database_properties.

Xcell-it Solutions, Ayyappa Society, Madhapur, Hyderabad. Contact:-9985296674, 040-64566226, 40202040

Satya Narayana Reddy

Surendra Reddy
9966990878

Diagram of tablespace

Xcell-it Solutions, Ayyappa Society, Madhapur, Hyderabad. Contact:-9985296674, 040-64566226, 40202040

Satya Narayana Reddy

Surendra Reddy
9966990878

Datafiles:
i)

is physical structure to store oracle data

ii)

One or more physical datafile are logically grouped together to make a tablespace

iii)

Information about Datafile can be obtained from view DBA_DATA_FILES

iv)

A Datafile can be associated with only one tablespace

1) How to Renaming and Relocating Datafiles?


To rename datafiles in a single tablespace, complete the following steps:
a. Take the tablespace that contains the datafiles offline. The database must be open.
For example
SQL> alter tablespace xcell offline normal;
b. Rename the datafiles using the operating system.
mv /d01/abs/oradata/john/hhh02.dbf /d02/xcell/oracle/oradata/xcell01.dbf
mv /d01/abs/oradata/john/hhh03.dbf /d02/xcell/oracle/oradata/xcell02.dbf
c. Use the ALTER TABLESPACE statement with the RENAME DATAFILE clause to change the
filenames within the database.
SQL>alter tablespace xcell rename datafile
'/d01/abs/oradata/john/xcell02.dbf','/d01/abs/oradata/john/xcell03.dbf'
TO '/d01/abs/oradata/john/xcell04.dbf','/d01/abs/oradata/john/xcell05.dbf';
d. Then Query the below statement.
SQL> SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES WHERE
TABLESPACE_NAME ='HHH';
e. Take the tablespace online.
SQL>alter tablespace xcell online;

Xcell-it Solutions, Ayyappa Society, Madhapur, Hyderabad. Contact:-9985296674, 040-64566226, 40202040

Satya Narayana Reddy

Surendra Reddy
9966990878

2). How to add datafile an existing tablesapce?


SQL> alter tablespace xcell add datafile '/d01/abs/oradata/john/suri.dbf' size 5m;
3).How to resize an existing datafile?
SQL> alter database datafile '/d01/abs/oradata/john/hhh04.dbf' resize 20m;
4).How to take offline a datafile?
SQL> alter database datafile '/d01/jess01.dbf' offline;
5).How to take a datafile online?
SQL>alter database datafile d01/jess01.dbf' online;
6).How to reuse datafile?
SQL> create tablespace suri datafile'/d01/muralitbs.dbf' reuse;
8) How to add a temp file an existing temporary tablespace?
SQL> alter tablespace temp add tempfile '/d01/oradata/db1/temp02.dbf' size 5m;
7).How to drop a tempfile?
SQL> alter database tempfile '/d01/oradata/db1/temp02.dbf' drop including datafiles;
SQL> alter tablespace temp drop tempfile '/d01/temp2.dbf';
8) How to drop a datafile?
SQL> alter tablespace suri drop datafile '/d01/suri.dbf';
9).How to assign temporary tablespace to database?
SQL>alter database default temporary tablespace temp;
10).How to assign a temporary tablespace to user?
SQL> alter user xcell temporary tablespace temp;
11). Views of datafiles and tempfiles.
DBA_DATA_FILES, DBA_TEMP_FILES,
V$DATAFILE, V$TEMPFILE,

Xcell-it Solutions, Ayyappa Society, Madhapur, Hyderabad. Contact:-9985296674, 040-64566226, 40202040

You might also like