柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!
全部博文(1669)
分类: Oracle
2012-01-10 09:19:31
由于空间问题,一个数据文件要移动一下。
步骤很简单!
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>