Posts

Showing posts from July, 2010

Format Shell Scripts

Cool and simple code to format any kind of script in Unix environment

awk.info » Format Shell Scripts

Recommended

Moving Control files and redo logfiles to a different filesystem

Background:
Dynamicaly moving control files and redo log files from filesystem /dbdata1/ to /dbdata3/ and from /dbdata2/ to /dbdata4/
1. run as sysdba
export ORACLE_SID=orcl
sqlplus / as sysdba
create pfile='pfile_backup_orcl.ora' from spfile;

SET pagesize 0
SET feedback off

spool OS_command_orcl.sh

SELECT 'cp ' || NAME || ' '
||
CASE
WHEN REGEXP_SUBSTR(NAME, '^\/[^/]+\/') = '/dbdata1/' THEN REPLACE (NAME, '/dbdata1/', '/dbdata3/')
WHEN REGEXP_SUBSTR(NAME, '^\/[^/]+\/') = '/dbdata2/' THEN REPLACE (NAME, '/dbdata2/', '/dbdata4/')
END OS_command
FROM v$controlfile
UNION ALL
SELECT
'cp ' || MEMBER || ' '
||CASE
WHEN REGEXP_SUBSTR(MEMBER, '^\/[^/]+\/') = '/dbdata1/'
THEN
REPLACE (MEMBER, '/dbdata1/', '/dbdata3/')
WHEN REGEXP_SUBSTR(MEMBER, '^\/[^/]+\/') = '/dbdata2/'
THEN
REPLACE (MEMBER, '/dbdata2/', '/dbdata4/')
END
OS_…