在12c以前如果想移动表空间的数据文件首先要offline.再OS mv命令移动离线的数据文件到新路径,Recover datafile[ or tablespace or database] 再Online.从12c 开始可以移动Online 的数据文件了。
1)Move a data file into ORACLE ASM
2)Move datafiles from one type of storage to another
3)Make a tablespace read-only and move its datafiles to write-once storage
4)Renames or relocates an online datafile data file at operating system level
5)Enables users to access the file during move datafile operation
6)When you relocate a data file on the Windows platform, the original data file might be retained in the old location, even when the KEEP option is omitted.
...
take a example.
sys@ORA12C>select status,enabled,name,con_id from v$datafile;
STATUS ENABLED NAME CON_ID
------- ---------- ------------------------------------------------------- --------------------
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/undotbs01.dbf 0
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/system01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/sysaux01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf 3
sys@ORA12C>alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf'
2 ;
Database altered.
sys@ORA12C>ho ls /u01/app/oracle/oradata/ora12c/pdb1/
ora_pdb1_users01.dbf sysaux01.dbf system01.dbf temp01.dbf
sys@ORA12C>select status,enabled,name,con_id from v$datafile;
STATUS ENABLED NAME CON_ID
------- ---------- ------------------------------------------------------- -------------------------
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/undotbs01.dbf 0
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/system01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/sysaux01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf 3
sys@ORA12C>alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' keep;
Database altered.
sys@ORA12C>ho ls /u01/app/oracle/oradata/ora12c/pdb1/
ora_pdb1_users01.dbf pdb1_users01.dbf sysaux01.dbf system01.dbf temp01.dbf
c##anbob@ORA12C>conn / as sysdba
Connected.
sys@ORA12C>alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf';
alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf'
*
ERROR at line 1:
ORA-01516: nonexistent log file, data file, or temporary file "10"
sys@ORA12C>select status,enabled,name,con_id from v$datafile;
STATUS ENABLED NAME CON_ID
------- ---------- --------------------------------------------------------------------------
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/system01.dbf 1
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/sysaux01.dbf 1
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/undotbs01.dbf 1
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/pdbseed/system01.dbf 2
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/users01.dbf 1
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdbseed/sysaux01.dbf 2
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/system01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/sysaux01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf 3
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/pdb2/system01.dbf 4
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb2/sysaux01.dbf 4
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/drmdb/system01.dbf 5
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/drmdb/sysaux01.dbf 5
13 rows selected.
sys@ORA12C>alter session set container=pdb1;
Session altered.
sys@ORA12C>select status,enabled,name,con_id from v$datafile;
STATUS ENABLED NAME CON_ID
------- ---------- --------------------------------------------------------------------------
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/undotbs01.dbf 0
SYSTEM READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/system01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/sysaux01.dbf 3
ONLINE READ WRITE /u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf 3
sys@ORA12C>alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf';
alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf'
*
ERROR at line 1:
ORA-01119: error in creating database file '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf'
ORA-27038: created file already exists
Additional information: 1
sys@ORA12C>alter database move datafile '/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf' to '/u01/app/oracle/oradata/ora12c/pdb1/ora_pdb1_users01.dbf' reuse;
Database altered.复制
sys@ORA12C>select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- --------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
PL/SQL Release 12.1.0.1.0 - Production 0
CORE 12.1.0.1.0 Production 0
TNS for Linux: Version 12.1.0.1.0 - Production 0
NLSRTL Version 12.1.0.1.0 - Production 0
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
638次阅读
2025-04-18 14:18:38
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
619次阅读
2025-04-15 17:24:06
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
518次阅读
2025-04-20 10:07:02
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
518次阅读
2025-04-08 09:12:48
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
476次阅读
2025-04-22 00:20:37
Oracle 19c RAC更换IP实战,运维必看!
szrsu
453次阅读
2025-04-08 23:57:08
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
451次阅读
2025-04-17 17:02:24
一页概览:Oracle GoldenGate
甲骨文云技术
450次阅读
2025-04-30 12:17:56
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
448次阅读
2025-04-22 00:13:51
火焰图--分析复杂SQL执行计划的利器
听见风的声音
396次阅读
2025-04-17 09:30:30
热门文章
移除DataGuard Standby配置导致Primary启动失败
2023-08-17 21335浏览
使用dblink产生的”SELECT /*+ FULL(P) +*/ * FROM XXXXX P ” 解析
2023-06-20 20901浏览
Troubleshooting 'ORA-28041: Authentication protocol internal error' change password 12c R2 DB
2020-04-08 13685浏览
浅谈ORACLE免费数据库Oracle Database XE (Express Edition) 版
2018-10-31 7651浏览
High wait event ‘row cache mutex’ in 12cR2、19c
2020-08-14 5601浏览