更改Oracle数据文件名及数据文件存放路径
SQL> select * from v$dbfile;        FILE# NAME ---------- --------------------------------------------------------------------------------          1 /db2/oracle/oradata/db2/system01.dbf          2 /db2/oracle/oradata/db2/sysaux01.dbf          3 /db2/oracle/oradata/db2/undotbs01.dbf          4 /db2/oracle/oradata/db2/users01.dbf          5 /db2/oracle/product/11.2.0/db_1/dbs/D:ORACLE11GADMINORADATAADMINgg01.dbf          6 /db2/oracle/oradata/db2/db201.dbf
一、关闭数据库进行修改 [oracle@db1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 26 17:43:38 2012
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
[oracle@db1 ~]$ mv /db2/oracle/product/11.2.0/db_1/dbs/D\:ORACLE11GADMINORADATAADMINgg01.dbf  /db2/oracle/oradata/db2/gg01.dbf
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 26 17:48:31 2012
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup mount ORACLE instance started.
Total System Global Area  521936896 bytes Fixed Size      2214936 bytes Variable Size    163578856 bytes Database Buffers   352321536 bytes Redo Buffers      3821568 bytes Database mounted.
SQL> alter database rename file '/db2/oracle/product/11.2.0/db_1/dbs/D\:ORACLE11GADMINORADATAADMINgg01.dbf' to '/db2/oracle/oradata/db2/gg01.dbf';
Database altered.
SQL> select * from v$dbfile;        FILE# NAME ---------- --------------------------------------------------------------------------------          1 /db2/oracle/oradata/db2/system01.dbf          2 /db2/oracle/oradata/db2/sysaux01.dbf          3 /db2/oracle/oradata/db2/undotbs01.dbf          4 /db2/oracle/oradata/db2/users01.dbf          5 /db2/oracle/oradata/db2/gg01.dbf          6 /db2/oracle/oradata/db2/db201.dbf   6 rows selected
二、在线修改 方法1:表空间offline SQL> select  *  from dba_data_files;   FILE_NAME                                                                           FILE_ID TABLESPACE_NAME                     BYTES     BLOCKS STATUS    RELATIVE_FNO AUTOEXTENSIBLE   MAXBYTES  MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS -------------------------------------------------------------------------------- ---------- ------------------------------ ---------- ---------- --------- ------------ -------------- ---------- ---------- ------------ ---------- ----------- ------------- /db2/oracle/oradata/db2/system01.dbf                                                      1 SYSTEM                          734003200      89600 AVAILABLE            1 YES            3435972198    4194302         1280  732954624       89472 SYSTEM /db2/oracle/oradata/db2/sysaux01.dbf                                                      2 SYSAUX                          629145600      76800 AVAILABLE            2 YES            3435972198    4194302         1280  628097024       76672 ONLINE /db2/oracle/oradata/db2/undotbs01.dbf                                                     3 UNDOTBS1                        618659840      75520 AVAILABLE            3 YES            3435972198    4194302          640  617611264       75392 ONLINE /db2/oracle/oradata/db2/users01.dbf                                                       4 USERS                             5242880        640 AVAILABLE            4 YES            3435972198    4194302          160    4194304         512 ONLINE /db2/oracle/oradata/db2/gg01.dbf                                                          5 GG                              104857600      12800 AVAILABLE            5 NO                      0          0            0  103809024       12672 ONLINE /db2/oracle/oradata/db2/db201.dbf                                                         6 DB2                             104857600      12800 AVAILABLE            6 NO                      0          0            0  103809024       12672 ONLINE   SQL> alter tablespace gg offline;   Tablespace altered
SQL> host mv /db2/oracle/oradata/db2/gg01.dbf /db2/oracle/oradata/db2/admin.dbf
SQL> alter database rename file '/db2/oracle/oradata/db2/gg01.dbf' to '/db2/oracle/oradata/db2/admin.dbf';   Database altered
SQL> alter tablespace gg online;   Tablespace altered
SQL> select  *  from dba_data_files;   FILE_NAME                                                                           FILE_ID TABLESPACE_NAME                     BYTES     BLOCKS STATUS    RELATIVE_FNO AUTOEXTENSIBLE   MAXBYTES  MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS -------------------------------------------------------------------------------- ---------- ------------------------------ ---------- ---------- --------- ------------ -------------- ---------- ---------- ------------ ---------- ----------- ------------- /db2/oracle/oradata/db2/system01.dbf                                                      1 SYSTEM                          734003200      89600 AVAILABLE            1 YES            3435972198    4194302         1280  732954624       89472 SYSTEM /db2/oracle/oradata/db2/sysaux01.dbf                                                      2 SYSAUX                          629145600      76800 AVAILABLE            2 YES            3435972198    4194302         1280  628097024       76672 ONLINE /db2/oracle/oradata/db2/undotbs01.dbf                                                     3 UNDOTBS1                        618659840      75520 AVAILABLE            3 YES            3435972198    4194302          640  617611264       75392 ONLINE /db2/oracle/oradata/db2/users01.dbf                                                       4 USERS                             5242880        640 AVAILABLE            4 YES            3435972198    4194302          160    4194304         512 ONLINE /db2/oracle/oradata/db2/admin.dbf                                                         5 GG                              104857600      12800 AVAILABLE            5 NO                      0          0            0  103809024       12672 ONLINE /db2/oracle/oradata/db2/db201.dbf                                                         6 DB2                             104857600      12800 AVAILABLE            6 NO                      0          0            0  103809024       12672 ONLINE   方法2:数据文件脱机 (方法2必须在数据库归档模式下进行) SQL> alter database datafile 5 offline; alter database datafile 5 offline * ERROR at line 1: ORA-01145: offline immediate disallowed unless media recovery enabled
SQL> archive log list; Database log mode        No Archive Mode Automatic archival        Disabled Archive destination        USE_DB_RECOVERY_FILE_DEST Oldest online log sequence     69 Current log sequence        71
开归档 [oracle@db1 ~]$ mkdir /db2/oracle/archivelog [oracle@db1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 26 18:15:52 2012
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
SQL> startup mount ORACLE instance started.
Total System Global Area  521936896 bytes Fixed Size      2214936 bytes Variable Size    163578856 bytes Database Buffers   352321536 bytes Redo Buffers      3821568 bytes Database mounted. SQL> alter system set log_archive_dest_1='location=/db2/oracle/archivelog/';
System altered.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list Database log mode        Archive Mode Automatic archival        Enabled Archive destination        /db2/oracle/archivelog/ Oldest online log sequence     69 Next log sequence to archive   71 Current log sequence        71
SQL> alter database datafile 5 offline;
Database altered.
SQL> host mv /db2/oracle/oradata/db2/admin.dbf /db2/oracle/oradata/db2/gg01.dbf
SQL> alter database rename file '/db2/oracle/oradata/db2/admin.dbf' to '/db2/oracle/oradata/db2/gg01.dbf';
Database altered.
SQL> alter database datafile 5 online; alter database datafile 5 online * ERROR at line 1: ORA-01113: file 5 needs media recovery ORA-01110: data file 5: '/db2/oracle/oradata/db2/gg01.dbf'
SQL> recover datafile 5; Media recovery complete.
SQL> alter database datafile 5 online;
Database altered.
SQL> select file_id,file_name,tablespace_name,online_status from dba_data_files;      FILE_ID FILE_NAME                                                                        TABLESPACE_NAME                ONLINE_STATUS ---------- -------------------------------------------------------------------------------- ------------------------------ -------------          1 /db2/oracle/oradata/db2/system01.dbf                                             SYSTEM                         SYSTEM          2 /db2/oracle/oradata/db2/sysaux01.dbf                                             SYSAUX                         ONLINE          3 /db2/oracle/oradata/db2/undotbs01.dbf                                            UNDOTBS1                       ONLINE          4 /db2/oracle/oradata/db2/users01.dbf                                              USERS                          ONLINE          5 /db2/oracle/oradata/db2/gg01.dbf                                                 GG                             ONLINE          6 /db2/oracle/oradata/db2/db201.dbf                                                DB2                            ONLINE  

更改Oracle数据文件名及数据文件存放路径的更多相关文章

  1. Oracle数据库克隆后temp文件因路径变化无法找到问题

    Oracle数据库克隆后temp文件因路径变化无法找到出现如下报错Errors in filexxxx.trc:ORA-01157: cannot identify/lock data file xx ...

  2. 更改Outlook 2013中Exchange数据文件存放路径

    昨天新入职目前所在的公司,在原公司一直都是直接使用Outlook设置用户名和密码后,然后将*.pst邮件的数据文件保存在其他盘符,以防止在更新操作系统时出现邮件丢失的情况:但是目前公司使用的是Exch ...

  3. Android 文件存放路径【转】

    对于应用携带的静态数据,可以放置在应用的assets目录或者res,raw目录下.对于assets目录下的静态数据,存在当文件最大支持1MB的局限,读取方式如下: 1 InputStream is = ...

  4. python——在文件存放路径下自动创建文件夹!

    1.a.py文件存放的路径下为(D:\Auto\eclipse\workspace\Testhtml\Test) 2.通过os.getcwd()获取的路径为:D:\Auto\eclipse\works ...

  5. 查询_修改SQL Server 2005中数据库文件存放路径

    1.查看当前的存放路径: select database_id,name,physical_name AS CurrentLocation,state_desc,size from sys.maste ...

  6. 查找mysql数据文件存放路径

    show variables like 'datadir%'; show variables当前的会话,是系统参数 是静态 show global variables全局 show status是系统 ...

  7. 如何快速查看mysql数据文件存放路径?

    进入mysql终端 mysql>show variables like '%datadir%'; 出来的结果即是!

  8. crontab -e文件存放路径

    crontab -e结果存放在/var/spool/cron/crontabs中

  9. oracle数据库备份、还原 (如何将Oracle 11g备份的dat文件导入到10g数据库里面)

    如何将Oracle 11g备份的dat文件导入到10g数据库里面 解决方法:      导出的时候后面加上目标数据库的版本号   导出: 在SQL plus下执行:create or replace  ...

随机推荐

  1. Iterator(迭代器模式)--(超市管理者)

    这个Iterator就是收银台干的活. package patterns.actions.iterator; public interface IteratorList { boolean isEmp ...

  2. Mule与其它web应用服务器的区别

    跟JBoss.Tomcat或其它web应用服务器相比,Mule有何不同?虽然他们有一些重要的相同点,不同点可以归结为你想达到的目标是什么.某些种类的应用对于Mule来说比较容易去编写.部署和管理,其它 ...

  3. android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams

      http://blog.csdn.net/lilu_leo/article/details/11952717 有时候需要在在代码中设置LayoutParams,自己为一个FrameLayout设置 ...

  4. myql 注意事项

    在[mysqld]下加入一行:lower_case_table_names=1,1为不区分大小写,0是区分大小写...并/etc/init.d/mysql restart即可...

  5. 用邻接表实现DFS和BFS

    #include <stdio.h> #include <stdlib.h> #define MAXVERTEX 10 typedef char VertexType; //顶 ...

  6. Linux下Matlab崩溃的解决方法

    猜想主要是因为图形显示用了OpenGL加速造成不稳定. 我的运行环境是: Ubuntu 10.04 LTS 64bit Matlab R2010b 解决方法是启动时用: $MATLAB_DIR/bin ...

  7. Java文件IO操作应该抛弃File拥抱Path和Files

    Java7中文件IO发生了很大的变化,专门引入了很多新的类: import java.nio.file.DirectoryStream;import java.nio.file.FileSystem; ...

  8. 利用js闭包获取索引号

    以tab选项卡效果为例: 网页中的选项卡效果

  9. PHP面试题之小杂鱼

    这里的题目都是比较老的,但是做笔试题时经常碰到,因为这些题目比较凌乱,考的知识点不好分类,就放一块了 /** * 题目:最少代码实现求3个数的最大值 * 三目运算符实现 */ function get ...

  10. makefile死磕笔记

    开始我会插播一段我如何学习makefile的废话,如果不想听的话,请直接跳到我的makefile教程. 首先得先说明学习makefile真是一个痛苦的过程,尤其是用干巴巴的看书来学习的过程,简直可以用 ...