Useful shortcuts for vi editor

Showing posts with label db file. Show all posts
Showing posts with label db file. Show all posts

Tuesday 31 January 2017

How to remove datafile carefully?

find datafile path;
SQL> 
select file_name from dba_data_files;

before run rm;
$ cd /oradata
$ lsof *
$ rm -f alper_data_01.dbf

Thursday 23 April 2015

How to transfer database file in Windows?

To do that please follow the instructions;

Tablespace: ALPER_DATA

Database file: data_01.dbf
DB file path: C:\Databasefiles
New database file name: data_new_01.dbf
New DB file path: D:\Databasefiles

Type these commands and press enter;

Example of offline transfer (database runs as non-archivelog mode)

Tablespace goes offline;
  • sqlplus / as sysdba 
  • alter tablespace ALPER_DATA offline;
  • exit
  • move C:\Databasefiles\data_01.dbf D:\Databasefiles\data_new_01.dbf
Datafile location info updates in database;
  • sqlplus / as sysdba
  • alter tablespace ALPER_DATA rename datafile 'C:\Databasefiles\data_01.dbf' to 'D:\Databasefiles\data_new_01.dbf';
  • alter tablespace ALPER_DATA online;
  • exit
Example of online transfer (database runs as archivelog mode)

Datafile goes offline;
  • sqlplus / as sysdba
  • alter database datafile 'C:\tablespaces\alper_01.dbf' offline;
  • exit
  • move C:\Databasefiles\data_01.dbf D:\Databasefiles\data_new_01.dbf
Datafile location info updates in database;
  • sqlplus / as sysdba
  • alter tablespace ALPER_DATA rename datafile 'C:\Databasefiles\data_01.dbf' to 'D:\Databasefiles\data_new_01.dbf';
  • recover datafile 'D:\Databasefiles\data_new_01.dbf'
  • alter database datafile 'D:\Databasefiles\data_new_01.dbf' online;
  • exit
Bye :)

Sunday 26 October 2014

How to define a tablespace in Windows?

Please execute the commands as "sys";

To define the tablespace:
SQL> CREATE TABLESPACE ALPER_DATA 
DATAFILE 'C:\tablespaces\data_01.dbf' SIZE 128M

To alter the tablespace:
SQL> ALTER TABLESPACE ALPER_DATA ADD DATAFILE 'C:\tablespaces\data_new_02.dbf' size 128m;

To drop the datafile from the tablespace:
SQL> ALTER TABLESPACE ALPER_DATA DROP DATAFILE 'C:\tablespaces\data_new_02.dbf';

To drop the tablespace:
SQL> DROP TABLESPACE ALPER_DATA 
INCLUDING CONTENTS AND DATAFILES;

To check tablespace's database files:
SQL> SELECT NAME, FILE#, STATUS FROM V$DATAFILE;

Used Oracle Version and OS: Oracle XE and Win7