Monday, July 14, 2014

Moving or Renaming Data Files While the Database is Online.


C:\Users\rajib.pradhan>SET ORACLE_SID=DBRMAN

C:\Users\rajib.pradhan>SQLPLUS /NOLOG

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 14 14:46:17 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

SQL> CONN SYS /AS SYSDBA
Enter password:
Connected.
SQL>
SQL> SELECT FILE_NAME FROM DBA_DATA_FILES;

FILE_NAME
--------------------------------------------------------------------------------
D:\APP\ORADATA\DBRMAN\USERS01.DBF
D:\APP\ORADATA\DBRMAN\UNDOTBS01.DBF
D:\APP\ORADATA\DBRMAN\SYSAUX01.DBF
D:\APP\ORADATA\DBRMAN\SYSTEM01.DBF
D:\APP\ORADATA\DBRMAN\CATALOG_SPC01.DBF
D:\APP\ORADATA\DBRMAN\TBS_RAMN_CAT_01.DBF
D:\APP\ORADATA\DBRMAN\TEST01.DBF

7 rows selected.

SQL> ALTER TABLESPACE TEST OFFLINE;

Tablespace altered.

SQL> CONN TEST/TEST;
Connected.
SQL> SELECT * FROM TAB;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
READ_ONLY                      TABLE
TEST_DATA                      TABLE

SQL> DESC TEST_DATA;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER
 NAME                                               VARCHAR2(300)

SQL> SELECT TABLE_NAME, TABLESPACE_NAME FROM USER_TABLES
  2  WHERE TABLE_NAME='TEST_DATA';

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
TEST_DATA                      TEST

SQL> INSERT INTO TEST_DATA VALUES(10,'RAJIB');
INSERT INTO TEST_DATA VALUES(10,'RAJIB')
            *
ERROR at line 1:
ORA-00376: file 7 cannot be read at this time
ORA-01110: data file 7: 'D:\APP\ORADATA\TEST01.DBF'


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\Users\rajib.pradhan>move D:\app\oradata\DBRMAN\TEST01.DBF D:\app\oradata\TEST01.DBF
        1 file(s) moved.

C:\Users\rajib.pradhan>SET ORACLE_SID=DBRMAN

C:\Users\rajib.pradhan>SQLPLUS /NOLOG

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 14 14:52:10 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

SQL> CONN SYS /AS SYSDBA
Enter password:
Connected.
SQL>
SQL> ALTER DATABASE RENAME FILE 'D:\APP\ORADATA\DBRMAN\TEST01.DBF' TO 'D:\app\oradata\TEST01.DBF';

Database altered.

SQL> ALTER TABLESPACE TEST ONLINE;

Tablespace altered.

SQL> SELECT FILE_NAME FROM DBA_DATA_FILES;

FILE_NAME
--------------------------------------------------------------------------------
D:\APP\ORADATA\DBRMAN\USERS01.DBF
D:\APP\ORADATA\DBRMAN\UNDOTBS01.DBF
D:\APP\ORADATA\DBRMAN\SYSAUX01.DBF
D:\APP\ORADATA\DBRMAN\SYSTEM01.DBF
D:\APP\ORADATA\DBRMAN\CATALOG_SPC01.DBF
D:\APP\ORADATA\DBRMAN\TBS_RAMN_CAT_01.DBF
D:\APP\ORADATA\TEST01.DBF

7 rows selected.

SQL>

No comments:

Post a Comment