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

Datafile Management: Steps To Make Datafile Off Line and Online

This document outlines steps for making a datafile offline and online, resizing a datafile, adding a datafile to a tablespace, and renaming a datafile in an Oracle database. The steps involve using SQL commands like ALTER DATABASE, ALTER TABLESPACE, and queries to V$DATAFILE and DBA_DATA_FILES to modify datafile properties and monitor their status and attributes.

Uploaded by

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

Datafile Management: Steps To Make Datafile Off Line and Online

This document outlines steps for making a datafile offline and online, resizing a datafile, adding a datafile to a tablespace, and renaming a datafile in an Oracle database. The steps involve using SQL commands like ALTER DATABASE, ALTER TABLESPACE, and queries to V$DATAFILE and DBA_DATA_FILES to modify datafile properties and monitor their status and attributes.

Uploaded by

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

DataFile Management

Posted by Narashim Reddy .R on August 16, 2009

3 Votes

Steps to Make datafile off line and online:


SQL> select file#,ts#,status,bytes,name from v$datafile where file#=10;
FILE# TS# STATUS BYTES
- - - NAME

10 5 ONLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
SQL> alter database datafile 10 offline;
Database altered.
SQL> select file#,ts#,status,bytes,name from v$datafile where file#=10;
FILE# TS# STATUS BYTES
- - - NAME

10 5 RECOVER 10485760
/home/oracle/tarun4/datafiles/users01.dbf
SQL> recover datafile 10;
Media recovery complete.
SQL> select file#,ts#,status,bytes,name from v$datafile where file#=10;
FILE# TS# STATUS BYTES
- - - NAME

10 5 OFFLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
SQL> alter database datafile 10 online;
Database altered.
SQL> select file#,ts#,status,bytes,name from v$datafile where file#=10;

FILE# TS# STATUS BYTES


- - - NAME

10 5 ONLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
Steps for Resizing the Datafile:
SQL> select file_name from dba_data_files where tablespace_name=USERS;
FILE_NAME
/home/oracle/tarun4/datafiles/users.dbf
SQL> select tablespace_name,bytes/1024/1024 from dba_data_files where
tablespace_name=USERS;
TABLESPACE_NAME BYTES/1024/1024

USERS 100
SQL> alter database
datafile/home/oracle/tarun4/datafiles/users.dbf resize 50m;
Database altered.
SQL> select tablespace_name,bytes/1024/1024 from dba_data_files where
tablespace_name=USERS;
TABLESPACE_NAME BYTES/1024/1024

USERS 50
Steps for adding a Datafile to Tablespace:
SQL> select file_name from dba_data_files where tablespace_name=USERS;
FILE_NAME

/home/oracle/tarun4/datafiles/users.dbf
SQL> alter tablespace
users add datafile/home/oracle/tarun4/datafiles/users1.dbf size 10m;
Tablespace altered.
SQL> select file_name from dba_data_files where tablespace_name=USERS;
FILE_NAME

/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users1.dbf

Steps for Rename the Datafile:


SQL> select file_name from dba_data_files where tablespace_name=USERS;
FILE_NAME

/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users1.dbf
SQL> alter tablespace users offline;
Tablespace altered.
SQL> !

[oracle@reddy ~]$ cd tarun4/datafiles/


[oracle@reddy datafiles]$ mv users1.dbf users01.dbf
SQL> alter tablespace
users rename datafile/home/oracle/tarun4/datafiles/users1.dbf to
/home/oracle/tarun4/datafiles/users01.dbf;
Tablespace altered.
SQL> alter tablespace users online;
Tablespace altered.
SQL> select file_name from dba_data_files where tablespace_name=USERS;
FILE_NAME

/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users01.dbf

You might also like