PL/SQL Scripts Used in Migrating to ASM Storage
来源:互联网 发布:数据库建设方案 编辑:程序博客网 时间:2024/06/15 03:26
PL/SQL Scripts Used in Migrating to ASM Storage
The following PL/SQL scripts perform tasks which arise in the migration scenarios
described in this chapter.
Generating ASM-to-Non-ASM Storage Migration Script
You can use the following PL/SQL script to generate a series of RMAN commands
that you can use to migrate your database back from ASM to non-ASM disk storage.
set serveroutput on;
declare
cursor df is select file#, name from v$datafile;
begin
dbms_output.put_line('run');
dbms_output.put_line('{');
for dfrec in df loop
dbms_output.put_line('set newname for datafile ' ||
dfrec.file# || ' to ''' || dfrec.name ||''' ;');
end loop;
dbms_output.put_line('restore database;');
dbms_output.put_line('switch all;');
dbms_output.put_line('}');
end;
Run this PL/SQL script and save the output into a file. The result is an RMAN script
which you can save to a file and later run as a command file in the RMAN client to
migrate your datafiles back out of ASM storage to their original non-ASM locations.
Even if you later add or delete datafiles, this script provides a useful starting point for
a migration script that will work for the new database.
Migrating Online Logs of Primary Database to ASM
The following PL/SQL script can be used to migrate the online redo log groups into
ASM, as part of migrating a database or a flash recovery area into ASM. For each
online redo log group, the script adds a log file stored in ASM, archives the current
redo logs, and then drops the non-ASM log file.
declare
cursor rlc is
select group# grp, thread# thr, bytes/1024 bytes_k, 'NO' srl
from v$log
union
select group# grp, thread# thr, bytes/1024 bytes_k, 'YES' srl
from v$standby_log
order by 1;
stmt varchar2(2048);
swtstmt varchar2(1024) := 'alter system switch logfile';
ckpstmt varchar2(1024) := 'alter system checkpoint global';
begin
for rlcRec in rlc loop
if (rlcRec.srl = 'YES') then
stmt := 'alter database add standby logfile thread ' ||
rlcRec.thr || ' ''+DISK'' size ' ||
rlcRec.bytes_k || 'K';
execute immediate stmt;
stmt := 'alter database drop standby logfile group ' || rlcRec.grp;
execute immediate stmt;
else
stmt := 'alter database add logfile thread ' ||
rlcRec.thr || ' ''+DISK'' size ' ||
rlcRec.bytes_k || 'K';
execute immediate stmt;
begin
stmt := 'alter database drop logfile group ' || rlcRec.grp;
dbms_output.put_line(stmt);
execute immediate stmt;
exception
when others then
execute immediate swtstmt;
execute immediate ckpstmt;
execute immediate stmt;
end;
end if;
end loop;
end;
- PL/SQL Scripts Used in Migrating to ASM Storage
- Migrating a Database from ASM to Non-ASM Storage
- Migrating Voting Disk to ASM in 11gR2 Clusterware
- Migrating Databases To and From ASM with
- Migrating the Flash Recovery Area to ASM
- Migrating to WebView in Android 4.4
- Android-Migrating to WebView in Android 4.4
- Scripts in $AD_TOP/sql
- Daily used PL/SQL commands
- How to Prepare Storage for ASM
- How to Prepare Storage for ASM
- add disk to ASM(AIX RAC ASM STORAGE)
- Android API Guides---Migrating to WebView in Android 4.4
- 93 The ORACLE_SID environment variable is set to +ASM. ASMLIB is not used in the configuration. You
- Migrating a Database into ASM
- Migrating MySQL to Microsoft SQL Server 2000
- How to use PL SQL Developer in Ubuntu
- What’s the Right Way to Prevent SQL Injection in PHP Scripts?
- 出题心得
- Testlink+trac整合
- YUV格式详解 .
- 分享的是Android图像特效处理的小技巧,比如圆角、倒影、还有就是图片缩放、Drawable转化为Bitmap、Bitmap转化为Drawable等等
- 多态总结
- PL/SQL Scripts Used in Migrating to ASM Storage
- linux stat函数讲解
- 让NSArray支持 Key Value Coding 方法 (用 @n 检索)
- cocos2d-x TiledMap 黑边问题
- VC,MFC,C++内存映射类,使用模板
- XEN虚拟机复制
- Myeclipse整合flex4搭建java的Web项目
- live555学习笔记11-h264 RTP传输详解(3)
- linux下挂载u盘、iso镜像、光驱