移动数据文件!

由于空间问题,一个数据文件要移动一下。

步骤很简单!

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------

D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF
D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF
D:\ORACLE\ORADATA\ORCL\USERS01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\DATASML01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\DATAUSR01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\INDEXLRG01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\INDEXSML01.DBF

9 rows selected.

SQL> alter database rename file 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF' t
o 'F:\oradata\DATALRG01.DBF';
alter database rename file 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF' to 'F:
\oradata\DATALRG01.DBF'
*
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01121: cannot rename database file 5 - file is in use or recovery
ORA-01110: data file 5: 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF'


SQL> alter database datafile 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF' offl
ine;
alter database datafile 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF' 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 151
Current log sequence 153
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 644468736 bytes
Fixed Size 1376520 bytes
Variable Size 398462712 bytes
Database Buffers 239075328 bytes
Redo Buffers 5554176 bytes

SQL> alter database mount;

Database altered.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.


SQL> alter database datafile 5 offline;

Database altered.

Cut/paste the file to dest location.

Wait until it is done or will raise the error like this.

SQL> alter tablespace datalrg rename datafile 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DA
TALRG01.DBF' to 'F:\oradata\DATALRG01.DBF';
alter tablespace datalrg rename datafile 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG
01.DBF' to 'F:\oradata\DATALRG01.DBF'
*
ERROR at line 1:
ORA-01525: error in renaming data files
ORA-01141: error renaming data file 5 - new file 'F:\oradata\DATALRG01.DBF' not
found
ORA-01110: data file 5: 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DATALRG01.DBF'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 32) The process cannot access the file because it is being used
by another process.

When it is done then run the command.
SQL> alter tablespace datalrg rename datafile 'D:\ORACLE\PRODUCT\ORADATA\ORCL\DA
TALRG01.DBF' to 'F:\oradata\DATALRG01.DBF';

Tablespace altered.

SQL> show user
USER is "SYS"
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: 'F:\ORADATA\DATALRG01.DBF'


SQL> recover datafile 5;
Media recovery complete.
SQL> alter database datafile 5 online;

Database altered.

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------

D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF
D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF
D:\ORACLE\ORADATA\ORCL\USERS01.DBF
F:\ORADATA\DATALRG01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\DATASML01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\DATAUSR01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\INDEXLRG01.DBF
D:\ORACLE\PRODUCT\ORADATA\ORCL\INDEXSML01.DBF

9 rows selected.

SQL>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值