Oracle 修改数据文件的路径和名称

Microsoft Windows XP [版本 5.1.2600] (C) 版权所有 1985-2001 Microsoft Corp. C:/Documents and Settings/Admin>sqlplus "/ as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Fri Nov 20 19:31:44 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> select file_name from dba_data_files; FILE_NAME -------------------------------------------------------------------------------- D:/ORACLE/ORADATA/ORCL/USERS01.DBF D:/ORACLE/ORADATA/ORCL/SYSAUX01.DBF D:/ORACLE/ORADATA/ORCL/UNDOTBS01.DBF D:/ORACLE/ORADATA/ORCL/SYSTEM01.DBF D:/ORACLE/ORADATA/ORCL/EXAMPLE01.DBF SQL> create tablespace test; //由于我使用了OMF功能 所以此处ORACLE会自动指定数据文件名、大小与路径 Tablespace created. SQL> select file_name from dba_data_files; FILE_NAME -------------------------------------------------------------------------------- D:/ORACLE/ORADATA/ORCL/USERS01.DBF D:/ORACLE/ORADATA/ORCL/SYSAUX01.DBF D:/ORACLE/ORADATA/ORCL/UNDOTBS01.DBF D:/ORACLE/ORADATA/ORCL/SYSTEM01.DBF D:/ORACLE/ORADATA/ORCL/EXAMPLE01.DBF D:/ORACLE/DB_CREATE_FILE_DEST/ORCL/DATAFILE/O1_MF_TEST_5JDZLKB6_.DBF 6 rows selected. SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. /*这个时候把D:/ORACLE/DB_CREATE_FILE_DEST/ORCL/DATAFILE/O1_MF_TEST_5JDZLKB6_.DBF复制一份到D:/ORACLE/ORADATA/ORCL/O1_MF_TEST_5JDZLKB6_.DBF*/ SQL> startup mount ORACLE instance started. Total System Global Area 176160768 bytes Fixed Size 1247948 bytes Variable Size 88081716 bytes Database Buffers 83886080 bytes Redo Buffers 2945024 bytes Database mounted. SQL> alter database rename file 'D:/ORACLE/DB_CREATE_FILE_DEST/ORCL/DATAFILE/O1_ MF_TEST_5JDZLKB6_.DBF' to 'D:/ORACLE/ORADATA/ORCL/O1_MF_TEST_5JDZLKB6_.DBF'; //此处主要是更改控制文件中的内容 Database altered. SQL> alter database open; Database altered. SQL> select file_name from dba_data_files; FILE_NAME -------------------------------------------------------------------------------- D:/ORACLE/ORADATA/ORCL/USERS01.DBF D:/ORACLE/ORADATA/ORCL/SYSAUX01.DBF D:/ORACLE/ORADATA/ORCL/UNDOTBS01.DBF D:/ORACLE/ORADATA/ORCL/SYSTEM01.DBF D:/ORACLE/ORADATA/ORCL/EXAMPLE01.DBF D:/ORACLE/ORADATA/ORCL/O1_MF_TEST_5JDZLKB6_.DBF 6 rows selected. SQL> //大功告成 数据文件O1_MF_TEST_5JDZLKB6_.DBF的路径已经改好了

 

上面我只是简单的举了个移动数据文件的例子,如果你想改名或者操作其他数据文件,操作步骤如法炮制就可以了。

SQL> show parameter db_create_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      d:/oracle/db_create_file_dest

 

还可以注意到一点的是,当我进行了如上操作以后,路径D:/ORACLE/DB_CREATE_FILE_DEST/ORCL/DATAFILE/下的数据文件已经自动消失了(当时我是复制,不是剪切),估计由于是OMF功能,ORACLE自动给删除了吧。

你可能感兴趣的:(Oracle,Basics)