Thursday, March 15, 2012

Create Oracle Directories for as-is database creation.


On several situations we need to mimick database to lab environments. And to create directories as-is of the source database; found this cool query that can generate all related directory structure creation linux command for us.

select distinct dir from (
select 'mkdir -p '||regexp_replace(fname,'(^.*)/[^/]*$','\1') dir
from (
select name fname from v$controlfile
union all
select name from v$datafile
union all
select name from v$tempfile
union all
select member from v$logfile
)
union all
select 'mkdir -p '||value dir from v$parameter where isdefault='FALSE' and type=2 and not value like '%,%' and value like '/%'
)


No comments: