1. 程式人生 > >oracle表空間檔案系統遷移到ASM

oracle表空間檔案系統遷移到ASM

1.配置測試環境
建立資料表空間
create tablespace test logging datafile '/home/oracle/test.dbf' size 10m autoextend on next 10m maxsize 2048m extent management local;
建立使用者並指定表空間
create user test identified by 123456 default tablespace test;
給使用者授予許可權
grant connect,resource,dba to test;
建立表
sqlplus test/[email protected]
CREATE TABLE test2(userId number(8), username varchar2(40), tep number (20)) PARTITION BY RANGE (userId)(PARTITION p1 VALUES LESS THAN (10000), PARTITION p2 VALUES LESS THAN (20000), PARTITION p3 VALUES LESS THAN (30000) );
查詢當前使用者下的表:
select tname from tab;

2.檔案系統表空間遷移到ASM中去
rman target /
report schema; 查看錶空間
sql 'alter tablespace test offline';離線表空間
backup as copy datafile 5 format '+DATA';Copy型別備份表空間
switch datafile 5 to copy;切換表空間檔案到copy副本
sql 'alter tablespace test online';上線表空間
report schema;

sqlplus / as sysdba
select ts#,name from v$tablespace where name='TEST' union all select file#,name from v$datafile where ts#=6;
select * from v$dbfile;

sqlplus test/[email protected]
select tname from tab;