Skip to content

Instantly share code, notes, and snippets.

@Tracnac
Last active September 23, 2022 16:21
Show Gist options
  • Select an option

  • Save Tracnac/3a0c6506f7b6f2c1ec2e2eb3c8d82fd5 to your computer and use it in GitHub Desktop.

Select an option

Save Tracnac/3a0c6506f7b6f2c1ec2e2eb3c8d82fd5 to your computer and use it in GitHub Desktop.
Rman partial restore #oracle #rman

define rmanowner= -- Datafiles list -- Input Owner -- Base select df.file# from v$tablespace ts, v$datafile df where ts.ts#=df.ts# and ( ts.name in ('SYSTEM','SYSAUX') or ts.name in (select tablespace_name from dba_tablespaces where contents = 'UNDO')) union -- Owner select df.file# from v$tablespace ts, v$datafile df where ts.ts#=df.ts# and ts.name in (select tablespace_name from dba_segments where owner = '&rmanowner.') order by 1;

run{ set until sequence=212148 thread 1; restore datafile <>; }

define rmanowner= with datafiles_list as ( select df.file# fileid from v$tablespace ts, v$datafile df where ts.ts#=df.ts# and ( ts.name in ('SYSTEM','SYSAUX') or ts.name in (select tablespace_name from dba_tablespaces where contents = 'UNDO')) union -- Owner select df.file# fileid from v$tablespace ts, v$datafile df where ts.ts#=df.ts# and ts.name in (select tablespace_name from dba_segments where owner = '&rmanowner.') group by df.file#) select distinct '''' || ts.name || ''',' from v$tablespace ts, v$datafile df where ts.ts#=df.ts# and df.file# not in (select fileid from datafiles_list);

run{ set until sequence=212148 thread 1; recover database skip forever tablespace <>; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment