码迷,mamicode.com
首页 > 数据库 > 详细

Oracle数据文件改名

时间:2018-05-19 18:51:00      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:name   enable   AC   status   from   rom   read   ffline   app   

1. open状态改名

 
SYS@userdata>select tablespace_name,file#,file_name,v.status,v.enabled from dba_data_files d,v$datafile v where d.file_id=v.file#;

TABLESPACE_NAME       FILE#     FILE_NAME                                         STATUS               ENABLED
-------------------- ---------- ------------------------------------------------------------ --------------------- ------------------------------
SYSTEM                  1     /u01/app/oracle/oradata/userdata/system01.dbf               SYSTEM               READ WRITE
UNDOTBS1                2     /u01/app/oracle/oradata/userdata/undotbs01.dbf              ONLINE               READ WRITE
SYSAUX                  3     /u01/app/oracle/oradata/userdata/sysaux01.dbf               ONLINE               READ WRITE
USERS                   4     /u01/app/oracle/oradata/userdata/users01.dbf               ONLINE                READ WRITE
EXAMPLE                 5     /u01/app/oracle/oradata/userdata/example01.dbf               ONLINE               READ WRITE

SYS@userdata>
SYS@userdata>alter tablespace users offline;

Tablespace altered.

SYS@userdata>host cp /u01/app/oracle/oradata/userdata/users01.dbf /u01/app/oracle/oradata/userdata/users02.dbf

SYS@userdata>alter database rename file /u01/app/oracle/oradata/userdata/users01.dbfto /u01/app/oracle/oradata/userdata/users02.dbf;

Database altered.

SYS@userdata>alter tablespace users online;

Tablespace altered.

SYS@userdata>select tablespace_name,file#,file_name,v.status,v.enabled from dba_data_files d,v$datafile v where d.file_id=v.file#;

TABLESPACE_NAME       FILE#     FILE_NAME                                         STATUS               ENABLED
-------------------- ---------- ------------------------------------------------------------ --------------------- ------------------------------
SYSTEM                  1     /u01/app/oracle/oradata/userdata/system01.dbf               SYSTEM               READ WRITE
UNDOTBS1                2     /u01/app/oracle/oradata/userdata/undotbs01.dbf              ONLINE               READ WRITE
SYSAUX                  3     /u01/app/oracle/oradata/userdata/sysaux01.dbf               ONLINE               READ WRITE
USERS                   4     /u01/app/oracle/oradata/userdata/users02.dbf               ONLINE                READ WRITE
EXAMPLE                 5     /u01/app/oracle/oradata/userdata/example01.dbf               ONLINE               READ WRITE
 

 2. mount状态改名

 
SYS@userdata>select open_mode from v$database;

OPEN_MODE
------------------------------
MOUNTED

SYS@userdata>host cp /u01/app/oracle/oradata/userdata/users02.dbf /u01/app/oracle/oradata/userdata/users01.dbf

SYS@userdata>alter database rename file /u01/app/oracle/oradata/userdata/users02.dbfto /u01/app/oracle/oradata/userdata/users01.dbf;

Database altered.

SYS@userdata>alter database open;

Database altered.


SYS@userdata>select tablespace_name,file#,file_name,v.status,v.enabled from dba_data_files d,v$datafile v where d.file_id=v.file#;

TABLESPACE_NAME       FILE#     FILE_NAME                                         STATUS               ENABLED
-------------------- ---------- ------------------------------------------------------------ --------------------- ------------------------------
SYSTEM                  1     /u01/app/oracle/oradata/userdata/system01.dbf               SYSTEM               READ WRITE
UNDOTBS1                2     /u01/app/oracle/oradata/userdata/undotbs01.dbf              ONLINE               READ WRITE
SYSAUX                  3     /u01/app/oracle/oradata/userdata/sysaux01.dbf               ONLINE               READ WRITE
USERS                   4     /u01/app/oracle/oradata/userdata/users01.dbf               ONLINE                READ WRITE
EXAMPLE                 5     /u01/app/oracle/oradata/userdata/example01.dbf               ONLINE               READ WRITE
 

Oracle数据文件改名

标签:name   enable   AC   status   from   rom   read   ffline   app   

原文地址:https://www.cnblogs.com/hftian/p/9060665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!