Oracle to change the location of data files

Original link: https://www.linuxidc.com/Linux/2012-09/69631.htm

Method One: offline table space

1, offline tablespace: ALTER TABLESPACE tablespace_name Offline;
2, copy the data file to the new directory;
. 3, modify the rename table space, and modify the control file;
. 4, Online tablespace;

1, offline table space zerone

SQL> select name from v$datafile;
NAME

C: \ the Oracle \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ system01.dbf
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ UNDOTBS01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ SYSAUX01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ USERS01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ EXAMPLE01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ZERONE01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ RMANTS.DBF
7 has been selected row.
SQL> alter tablespace zerone offline;
table space has changed.
2, copy the data files to a new directory
to copy the data file C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ZERONE01.DBF to C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ ZERONE01.DBF.

3, rename the data file to modify the table space for the new location, and modify the control file

SQL> alter tablespace zerone rename datafile ' c: \ oracle \ product \ 10.2.0 \ oradata \ zerone01.dbf' to 'c: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ zerone01.dbf';
tablespace change.
4, online table space

SQL> alter tablespace zerone online;
table space has changed.
SQL> select name from v $ datafile ;

NAME
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZERONE01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\RMANTS.DBF
已选择7行。
SQL> select file_name,tablespace_name from dba_data_files where tablespace_name=‘ZERONE’;
FILE_NAME TABLESPACE_NAME

ZERONE C:\ORACLE\PRODUCT\10.2ORADATA\ORCL\ZERONE01.DBF

Method Two: SQL to modify the data file location

1, close the database;
2, copy the data files to a new location;
3, starting to mount state database;
4, modify the location of data files by the SQL;
. 5, open the database;

1, close the database

SQL> the SELECT name from v $ datafile;
NAME
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ system01.dbf
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ UNDOTBS01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ SYSAUX01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ USERS01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ EXAMPLE01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ ZERONE01.DBF
C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ RMANTS.DBF
7 has been selected row.
SQL> shutdown immediate;
Database closed.
Database has been uninstalled.
ORACLE instance shut down.
2, copy the data files to a new location;
the data file C: \ ORACLE \ PRODUCT \ 10.2.0 \ copy ORADATA \ ORCL \ ZERONE01.DBF to C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ZERONE01.DBF.

3, to start the mount state database;

SQL> Mount the Startup
ORACLE instance started.
Area System, Ltd. Free Join 167 772 160 bytes Total
Fixed Size 1.2479 million bytes
Variable Size 96,470,372 bytes
Database Buffers 67108864 bytes
Redo Buffers 2945024 bytes
database loading is completed.
4, by modifying the SQL file location data;

SQL> alter database rename file 'c : \ oracle \ product \ 10.2.0 \ oradata \ orcl \ zerone01.dbf' to 'c: \ oracle \ product \ 10.2.0 \ oradata \ zerone01.dbf';
the database has changed.
5, open the database;

SQL> alter database open;
数据库已更改。
SQL> select name from v$datafile;
NAME
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ZERONE01.DBF
C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\RMANTS.DBF
已选择7行。
SQL> select file_name,tablespace_name from dba_data_files where tablespace_name=‘ZERONE’;
FILE_NAME TABLESPACE_NAME

ZERONE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ZERONE01.DBF

Guess you like

Origin www.cnblogs.com/wxc6603/p/11928424.html