一个朋友不小心将表空间建在了文件系统上,需要转移到裸设备上,懒的做实验了,参考了一下eygle的实验。大家可以去做一下这个实验:
1.使用裸设备建立jiagulun测试表空间
[oracle@jiagulun ~]$ sqlplus "/ as sysDBA"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Nov 30 14:41:53 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL> create tablespace jiagulun
2 datafile '/dev/cciss/c0d0p11' size 10M;
Tablespace created.
SQL> create table jiagulun tablespace jiagulun as select * from dba_objects;
Table created.
SQL> select count(*) from jiagulun;
COUNT(*)
----------
50420
SQL> alter tablespace jiagulun offline;
Tablespace altered.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
2.使用RMAN的COPY功能备份裸设备文件为文件系统文件
[oracle@jiagulun ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 30 16:00:42 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: jiagulun (DBID=3965153484)
RMAN> copy datafile '/dev/cciss/c0d0p11' to '/opt/oracle/jiagulun01.dbf';
Starting backup at 30-NOV-05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=137 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/dev/cciss/c0d0p11
output filename=/opt/oracle/jiagulun01.dbf tag=TAG20051130T160137 recid=2 stamp=575740898
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
Finished backup at 30-NOV-05
RMAN> exit
Recovery Manager complete.
3.通过rename修改文件位置
[oracle@jiagulun ~]$ sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Nov 30 16:01:54 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL> alter database rename file '/dev/cciss/c0d0p11' to '/opt/oracle/jiagulun01.dbf';
Database altered.
SQL> alter tablespace jiagulun online;
Tablespace altered.
SQL> select file_name from dba_data_files where tablespace_name='jiagulun';
FILE_NAME
--------------------------------------------------------------------------------
/opt/oracle/jiagulun01.dbf
4.进行数据修改
SQL> insert into jiagulun as select * from jiagulun;
insert into jiagulun as select * from jiagulun
*
ERROR at line 1:
ORA-00926: missing VALUES keyword
SQL> insert into jiagulun select * from jiagulun;
insert into jiagulun select * from jiagulun
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.jiagulun by 128 in tablespace jiagulun
SQL> alter database datafile '/opt/oracle/jiagulun01.dbf' resize 20m;
Database altered.
SQL> insert into jiagulun select * from jiagulun;
50420 rows created.
SQL> commit;
Commit complete.
SQL> alter tablespace jiagulun offline;
Tablespace altered.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
5.从文件系统迁移文件至裸设备
[oracle@jiagulun ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 30 16:08:51 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: jiagulun (DBID=3965153484)
RMAN> copy datafile '/opt/oracle/jiagulun01.dbf' to '/dev/cciss/c0d0p11';
Starting backup at 30-NOV-05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=135 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/opt/oracle/jiagulun01.dbf
output filename=/dev/cciss/c0d0p11 tag=TAG20051130T160935 recid=3 stamp=575741376
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 30-NOV-05
RMAN> exit
Recovery Manager complete.
[oracle@jiagulun ~]$ sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Nov 30 16:09:48 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL> alter database rename file '/opt/oracle/jiagulun01.dbf' to '/dev/cciss/c0d0p11';
Database altered.
SQL> alter tablespace jiagulun online;
Tablespace altered.
SQL> select count(*) from jiagulun;
COUNT(*)
----------
100840
SQL>
rman使得对于裸设备的操作大大简化。
|
|