更改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
 
 
 
http://blog.itpub.net/26839123/viewspace-737001/

Oracle修改数据文件路径的更多相关文章

  1. oracle 修改数据文件路径

      一.关库修改文件位置 1.连接到数据库 [oracle@linux]$ ./sqlplus /nolog SQL> conn / as sysdba 2. 查看数据文件位置 SQL>  ...

  2. Oracle 修改数据文件路径的方法

      1. 关闭数据库,然后启动至mount状态 sqlplus / as sysdba shutdown immediate startup mount 2. 修改物理文件: 我这边将: c:\cwd ...

  3. oracle移动数据/修改数据文件路径

    参考:http://wwyz998.blog.163.com/blog/static/321867852011117111832334/ oracle移动数据文件 1.连接到数据库 [oracle@l ...

  4. Oracle 修改trace 文件路径

    修改trace 文件路径命令 适用于oracle 11G以后的版本 在集群环境中的2个节点都生效SQL> ALTER SYSTEM SET diagnostic_dest='/tmp' SCOP ...

  5. Oracle 11g R2(11.2.0.4) RAC 数据文件路径错误解决--ORA-01157 ORA-01110: 数据文件

    Oracle 11g R2(11.2.0.1) RAC  数据文件路径错误解决--ORA-01157 ORA-01110: 数据文件 oracle 11g R2(11.2.0.4) rac--scan ...

  6. oracle rename数据文件的两种方法

    oracle rename数据文件的两种方法 2012-12-11 20:44 10925人阅读 评论(0) 收藏 举报  分类: oracle(98)  版权声明:本文为博主原创文章,未经博主允许不 ...

  7. Oracle单个数据文件超过32G后扩容

    Oracle单个数据文件超过32G后扩容   表空间数据文件容量与DB_BLOCK_SIZE的设置有关,而这个参数在创建数据库实例的时候就已经指定.DB_BLOCK_SIZE参数可以设置为4K.8K. ...

  8. maven的安装、路径配置、修改库文件路径和eclipse中的配置、创建maven工程。

    注:本文来源于:杨四郎2018  <maven的安装.路径配置.修改库文件路径和eclipse中的配置.创建maven工程> 一.maven的安装 首先,先到官网去下载maven.这里是官 ...

  9. mysql修改数据存储路径报错处理

    Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'解决?: >>> vim ...

随机推荐

  1. k8s-calico【转载】

    环境 系统:centos7.3192.168.40.50 local-master192.168.40.51 local-node1192.168.40.52 local-node2 master: ...

  2. js中数组Array 详解

    unshift:将参数添加到原数组开头,并返回数组的长度    pop:删除原数组最后一项,并返回删除元素的值:如果数组为空则返回undefined    push:将参数添加到原数组末尾,并返回数组 ...

  3. linux0.11源码内核——系统调用,int80的实现细节

    linux0.11添加系统调用的步骤 假设添加一个系统调用foo() 1.修改include/linux/sys.h 添加声明 extern int foo(); 同时在sys_call_table数 ...

  4. 如何在浏览器上安装 VueDevtools工具

    火狐浏览器直接打开附加组件中,搜索 VueDevtools,找到安装即可. 谷歌浏览器--更多工具--扩展程序--打开下载好的VueDevtools整体拖进去就行了

  5. truncate与delete删除数据的区别

  6. react教程 — 组件的生命周期 和 执行顺序

    一.组件执行的生命周期:                  参考  https://www.cnblogs.com/soyxiaobi/p/9559117.html  或  https://www.c ...

  7. js练习题之图片背景轮播

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  8. Spring Boot学习一之Spring Beans和依赖注入

    你可以自由地使用任何标准的Spring框架技术去定义beans和它们注入的依赖.简单起见,我们经常使用 @ComponentScan 注解搜索beans,并结合 @Autowired 构造器注入. 如 ...

  9. python生成接口自动化测试报告模版

    1:准备html模版 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> &l ...

  10. css如何让<a>标签,根据输入的内容长度调整宽度,宽度自适应,那位大仙帮帮忙

    css如何让<a>标签,根据输入的内容长度调整宽度,宽度自适应,那位大仙帮帮忙 5 样式 .ceshi{float:left; margin-left:13px; width:180px; ...