1.alter database方法
该方法,可以移动任何表空间的数据文件。

***关闭数据库***
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

***移动数据文件,用oracle用户操作***
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/system01.dbf /oracledb/test/system01.dbf
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/sysaux01.dbf /oracledb/test/sysaux01.dbf
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/undotbs01.dbf /oracledb/test/undotbs01.dbf
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/users01.dbf /oracledb/test/users01.dbf
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/temp01.dbf /oracledb/test/temp01.dbf
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/redo03.log /oracledb/test/redo03.log
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/redo02.log /oracledb/test/redo02.log
[oracle@test ~]$ mv /u01/app/oracle/oradata/test/redo01.log /oracledb/test/redo01.log

***启动到mount状态***
SQL> startup mount
ORACLE instance started.

Total System Global Area 1.0122E+10 bytes
Fixed Size 2237088 bytes
Variable Size 1610616160 bytes
Database Buffers 8489271296 bytes
Redo Buffers 19468288 bytes
Database mounted.

SQL> alter database rename file '/u01/app/oracle/oradata/test/system01.dbf' to '/oracledb/test/system01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/sysaux01.dbf' to '/oracledb/test/sysaux01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/undotbs01.dbf' to '/oracledb/test/undotbs01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/users01.dbf' to '/oracledb/test/users01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/temp01.dbf' to '/oracledb/test/temp01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/redo01.log' to '/oracledb/test/redo01.log';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/redo02.log' to '/oracledb/test/redo02.log';

Database altered.

SQL> alter database rename file '/u01/app/oracle/oradata/test/redo03.log' to '/oracledb/test/redo03.log';

Database altered.

SQL> alter database open;

Database altered.

***重启验证***
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area 1.0122E+10 bytes
Fixed Size 2237088 bytes
Variable Size 1610616160 bytes
Database Buffers 8489271296 bytes
Redo Buffers 19468288 bytes
Database mounted.
Database opened.

2.alter tablespace方法
该方法,不能移动system表空间,回滚段表空间和临时段表空间的数据文件。

***offline system表空间时报错***
SQL> alter tablespace system offline;
alter tablespace system offline
*
ERROR at line 1:
ORA-01541: system tablespace cannot be brought offline; shut down if necessary
报错:说明system表空间不能offline
***由此说明一下system表空间的特性--不能脱机offline
--不能置为只读read only
--不能重命名
--不能删除

SQL> alter tablespace sysaux offline;

Tablespace altered.

[oracle@test ~]$ cp /oracledb/test/sysaux01.dbf /u01/app/oracle/oradata/test/sysaux01.dbf

SQL> alter tablespace sysaux rename datafile '/oracledb/test/sysaux01.dbf' to '/u01/app/oracle/oradata/test/sysaux01.dbf';

Tablespace altered.

SQL> alter tablespace sysaux online;

Tablespace altered.

***offline UNDO表空间时报错***
SQL> alter tablespace UNDOTBS1 offline;
alter tablespace UNDOTBS1 offline
*
ERROR at line 1:
ORA-30042: Cannot offline the undo tablespace

***offline TEMP表空间时报错***
SQL> alter tablespace TEMP offline;
alter tablespace TEMP offline
*
ERROR at line 1:
ORA-03217: invalid option for alter of TEMPORARY TABLESPACE

#把需要移动的数据文件对应的表空间offline
SQL> alter tablespace USERS offline;

Tablespace altered.

#移动数据文件至目标位置
[oracle@test ~]$ cp /oracledb/test/users01.dbf /u01/app/oracle/oradata/test/users01.dbf

#修改表空间中数据文件的位置
SQL> alter tablespace USERS rename datafile '/oracledb/test/users01.dbf' to '/u01/app/oracle/oradata/test/users01.dbf';

Tablespace altered.

#把表空间online
SQL> alter tablespace users online;

Tablespace altered.

3.总结
alter database方法可以移动任何表空间的数据文件,但其要求数据库必须处于mount状态,故此种方法更适合做整体数据库的迁移。
alter tablespace方法需要数据库处于open状态,表空间在offline的状态下才可更改。但其不能移动system表空间,undo表空间和temp表空间的数据文件,故此种方法更适合于做用户数据文件的迁移。

移动oracle数据文件的两种方法的更多相关文章

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

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

  2. MySQL命令执行sql文件的两种方法

    MySQL命令执行sql文件的两种方法 摘要:和其他数据库一样,MySQL也提供了命令执行sql脚本文件,方便地进行数据库.表以及数据等各种操作.下面笔者讲解MySQL执行sql文件命令的两种方法,希 ...

  3. [转载]C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 by 大龙哥 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char ...

  4. C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  5. Linux下查看alert日志文件的两种方法

    --linux下查看alert日志文件的两种方法: --方法1: SQL> show parameter background_dump_dest; NAME TYPE VALUE ------ ...

  6. C#读写txt文件的两种方法介绍[转]

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  7. C#读写txt文件的两种方法介绍 v

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  8. .net中创建xml文件的两种方法

    .net中创建xml文件的两种方法 方法1:根据xml结构一步一步构建xml文档,保存文件(动态方式) 方法2:直接加载xml结构,保存文件(固定方式) 方法1:动态创建xml文档 根据传递的值,构建 ...

  9. spring 配置文件 引入外部的property文件的两种方法

    spring  的配置文件 引入外部的property文件的两种方法 <!-- 引入jdbc配置文件    方法一 --> <bean id="propertyConfig ...

随机推荐

  1. how does SELECT TOP works when no order by is specified?

    how does SELECT TOP works when no order by is specified? There is no guarantee which two rows you ge ...

  2. [web 前端] Npm package.json与package-lock.json文件的作用

    本文链接:https://blog.csdn.net/u013992330/article/details/81110018 最新版nodejs中,多了一个package-lock.json文件,刚开 ...

  3. Netty执行流程分析与重要组件介绍

    一.环境搭建 创建工程,引入Netty依赖 二.基于Netty的请求响应Demo 1.TestHttpServerHandle  处理器.读取客户端发送过来的请求,并且向客户端返回hello worl ...

  4. Nginx配置SSL证书部署HTTPS网站(颁发证书)

    一.Http与Https的区别HTTP:是互联网上应用最为广泛的一种网络协议,是一个客户端和服务器端请求和应答的标准(TCP),用于从WWW服务器传输超文本到本地浏览器的传输协议,它可以使浏览器更加高 ...

  5. java8之Spliterator

    基本用法: import java.util.Arrays; import java.util.Spliterator; import java.util.stream.IntStream; publ ...

  6. Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型

    Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型 OxyPlot组件支持26种图表,这些图表按照功能和样式可以分为4大类,分别为线型图表.条型图表.金融图表和其它图表. 线型图表 ...

  7. Android dump命令查看某个apk是被谁安装的?

    adb shell dumpsys package packages > packageAll.txt     ORadb shell pm dump packages > package ...

  8. Python使用偏函数与类实现装饰器

    # -*- coding: utf-8 -*- # author:baoshan # python对某个对象是否能通过装饰器形式使用只有一个要求:decorator必须是一个可被调用的对象. # 我们 ...

  9. 《电子计算机机房设计规范》GB50174-93

    <电子计算机机房设计规范>GB50174-2008 http://gf.1190119.com/article-17886.htm 中华人民共和国国家标准 电子计算机机房设计规范 GB 5 ...

  10. Mac删除自带的abc输入法

    1. 安装软件:https://pan.baidu.com/s/15oIzTDojpignoR5MiZ-Q1A 安装并注册 2. 进入到目录,并打开: 1. /Users/toov5/Library/ ...