xtts可能用到的脚本

https://www.oracle.com/technetwork/database/features/availability/maa-wp-11g-platformmigrationtts-129269.pdf 

cr_tts_tsrw.sql Creates tts_tsrw.sql script from the source database. Use this script to set all tablespaces to READ WRITE mode after the transport process.
cr_tts_sys_privs.sql Creates tts_sys_privs.sql script from the source database. Use this script to create GRANT commands to be run on the target database to give privileges that are not handled by Data Pump.
cr_tts_create_seq.sql Creates tts_create_seq.sql script from the source database. Use this script to reset the proper starting value for sequences on the target database.
cr_tts_parfiles.sql Creates Data Pump parameter files for
 
XTTS export (dp_ttsexp.par)
 
XTTS import (dp_ttsimp.par)
 
Test tablespace metadata-only export (dp_tsmeta_exp_TESTONLY.par)
cr_tts_sys_privs.sql is a sample script that creates the tts_sys_privs.sql script from the source database. Use this script to create GRANT commands to be run on the target database to give privileges that are not handled by Data Pump.

cr_tts_drop_ts.sql is a sample script that creates tts_drop_ts.sql script from source database. Use this script to drop tablespaces in the target database prior to
the transport process.

cr_tts_tsro.sql is a sample script that creates the tts_tsro.sql script from the source database. Use this script to set all tablespaces to be transported to
READ-ONLY mode.
 
cr_tts_sys_privs.sql

set heading off feedback off trimspool on escape off set long 1000 linesize 1000
col USERDDL format A150 spool tts_sys_privs.sql prompt /* ============ */ prompt /* Grant privs */ prompt /* ============ */
select 'grant '||privilege||' on "'|| owner||'"."'||table_name||'" to "'||grantee||'"'|| decode(grantable,'YES',' with grant option ')|| decode(hierarchy,'YES',' with hierarchy option ')|| ';'
from dba_tab_privs where owner in
(select name
from system.logstdby$skip_support where action=0)
and grantee in (select username
from dba_users
where username not in (select name
from system.logstdby$skip_support where action=0)    );
spool off

cr_tts_drop_ts.sql
set heading off feedback off trimspool on linesize 500 spool tts_drop_ts.sql
prompt /* ===================== */ prompt /* Drop user tablespaces */ prompt /* ===================== */
select 'DROP TABLESPACE ' || tablespace_name || ' INCLUDING CONTENTS AND DATAFILES;'
from dba_tablespaces
where tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT';
spool off

cr_tts_tsro.sql
set heading off feedback off trimspool on linesize 500 spool tts_tsro.sql
prompt /* =================================== */
prompt /* Make all user tablespaces READ ONLY */ prompt /* =================================== */
select 'ALTER TABLESPACE ' || tablespace_name || ' READ ONLY;' from dba_tablespaces
where tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT';
spool off
 
cr_tts_tsrw.sql is a sample script that creates tts_tsrw.sql script from the source database. Use this script to set all tablespaces to READ WRITE mode after the
transport process.

cr_tts_create_seq.sql is a sample script that creates tts_create_seq.sql script from the source database. Use this script to reset the proper starting value for sequences on the target database.
 
cr_tts_tsrw.sql
set heading off feedback off trimspool on linesize 500 spool tts_tsrw.sql
prompt /* ==================================== */
prompt /* Make all user tablespaces READ WRITE */ prompt /* ==================================== */
select 'ALTER TABLESPACE ' || tablespace_name || ' READ WRITE;' from dba_tablespaces
where tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT';
spool off

cr_tts_create_seq.sql
set heading off feedback off trimspool on escape off set long 1000 linesize 1000 pagesize 0
col SEQDDL format A300 spool tts_create_seq.sql
prompt /* ========================= */
prompt /* Drop and create sequences */ prompt /* ========================= */
select regexp_replace( dbms_metadata.get_ddl('SEQUENCE',sequence_name,sequence_owner), '^.*(CREATE SEQUENCE.*CYCLE).*$',
'DROP SEQUENCE "'||sequence_owner||'"."'||sequence_name
||'";'||chr(10)||'\1;') SEQDDL
from dba_sequences
where sequence_owner not in (select name
from system.logstdby$skip_support where action=0)
;
spool off

 
cr_tts_parfiles.sql is a sample script that creates TTS export, TTS import, and test tablespace metadata-only export
Data Pump parameter files.
 
cr_tts_parfiles.sql
REM
REM Create TTS Data Pump export and import PAR files REM

set feedback off trimspool on set serveroutput on size 1000000

REM
REM Data Pump parameter file for TTS export REM
spool dp_ttsexp.par

declare
tsname varchar(30); i number := 0;
begin
dbms_output.put_line('directory=ttsdir'); dbms_output.put_line('dumpfile=dp_tts.dmp'); dbms_output.put_line('logfile=dp_ttsexp.log'); dbms_output.put_line('transport_full_check=no');
dbms_output.put('transport_tablespaces='); for ts in
(select tablespace_name from dba_tablespaces where tablespace_name not in ('SYSTEM','SYSAUX')
and contents = 'PERMANENT'
order by tablespace_name) loop
if (i!=0) then dbms_output.put_line(tsname||',');
end if; i := 1;
tsname := ts.tablespace_name; end loop; dbms_output.put_line(tsname); dbms_output.put_line('');
end;
/
spool off


REM
REM Data Pump parameter file for TTS import REM
spool dp_ttsimp.par

declare
fname varchar(513); i number := 0;
begin
dbms_output.put_line('directory=ttsdir'); dbms_output.put_line('dumpfile=dp_tts.dmp'); dbms_output.put_line('logfile=dp_ttsimp.log');
dbms_output.put('transport_datafiles='); for df in
(select file_name from dba_tablespaces a, dba_data_files b where a.tablespace_name = b.tablespace_name
and a.tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT'
order by a.tablespace_name) loop
if (i!=0) then dbms_output.put_line(''''||fname||''',');
end if; i := 1;
fname := df.file_name; end loop;
dbms_output.put_line(''''||fname||''''); dbms_output.put_line('');
end;
/
spool off


REM
REM Data Pump parameter file for tablespace metadata export REM Only use this to estimate the TTS export time
REM
spool dp_tsmeta_exp_TESTONLY.par

declare
tsname varchar(30); i number := 0;
begin
dbms_output.put_line('directory=ttsdir'); dbms_output.put_line('dumpfile=dp_tsmeta_TESTONLY.dmp');
dbms_output.put_line('logfile=dp_tsmeta_exp_TESTONLY.log'); dbms_output.put_line('content=metadata_only');
dbms_output.put('tablespaces='); for ts in
(select tablespace_name from dba_tablespaces where tablespace_name not in ('SYSTEM','SYSAUX')
and contents = 'PERMANENT' order by tablespace_name)
loop
if (i!=0) then dbms_output.put_line(tsname||',');
end if; i := 1;
tsname := ts.tablespace_name; end loop; dbms_output.put_line(tsname); dbms_output.put_line('');
end;
/
spool off

 
cr_rman_ts_convert.sql is a sample SQL script that generates an RMAN script to perform source system conversion during
XTTS platform migration.
 
cr_rman_ts_convert.sql
REM
REM Create RMAN CONVERT TABLESPACE script for cross platform TTS REM Use for source system conversion only
REM

set feedback off trimspool on set serveroutput on size 1000000
spool ts_convert.rman declare
tsname varchar(30);
i number := 0; begin
dbms_output.put_line('# Sample RMAN script to perform file conversion on all user tablespaces');
dbms_output.put_line('# Tablespace names taken from DBA_TABLESPACES');
dbms_output.put_line('# Please review and edit before using'); dbms_output.put_line('CONVERT TABLESPACE ');

for ts in
(select tablespace_name from dba_tablespaces where tablespace_name not in ('SYSTEM','SYSAUX')
and contents = 'PERMANENT' order by tablespace_name)
loop
if (i!=0) then dbms_output.put_line(tsname||',');
end if; i := 1;
tsname := ts.tablespace_name; end loop; dbms_output.put_line(tsname);
dbms_output.put_line('TO PLATFORM '''''); dbms_output.put_line('PARALLELISM 4');
dbms_output.put_line('DB_FILE_NAME_CONVERT ''/oradata/ORCL/datafile/'',''/stage/''');
dbms_output.put_line(';'); end;
/
spool off

 
cr_rman_df_convert.sql is a sample SQL script that generates an RMAN script to perform target system conversion during
XTTS platform migration.
tts_check.sql is a sample script that runs the DBMS_TTS.TRANSPORT_SET_CHECK
function that performs the self containment check for the list of tablespaces to be transported.
 
cr_rman_df_convert.sql
REM
REM Create RMAN CONVERT DATAFILE script for cross platform TTS REM Use for target system conversion only
REM

set feedback off trimspool on set serveroutput on size 1000000
spool df_convert.rman declare
fname varchar(513);
i number := 0; begin
dbms_output.put_line('# Sample RMAN script to perform file conversion on all user datafiles');
dbms_output.put_line('# Datafile names taken from DBA_DATA_FILES'); dbms_output.put_line('# Please review and edit before using'); dbms_output.put_line('CONVERT DATAFILE ');

for df in
(select substr(file_name,instr(file_name,'/',-1)+1) file_name from dba_tablespaces a, dba_data_files b
where a.tablespace_name = b.tablespace_name
and a.tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT'
order by a.tablespace_name) loop
if (i!=0) then dbms_output.put_line('''/stage/'||fname||''',');
end if; i := 1;
fname := df.file_name; end loop;
dbms_output.put_line('''/stage/'||fname||'''');
dbms_output.put_line('FROM PLATFORM ''''');
dbms_output.put_line('PARALLELISM 4'); dbms_output.put_line('DB_FILE_NAME_CONVERT   ''/stage/'',''+DATA/'''); dbms_output.put_line(';');
end;
/
spool off

tts_check.sql
declare
checklist varchar2(4000); i number := 0;
begin
for ts in
(select tablespace_name
from dba_tablespaces
where tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT')
loop
if (i=0) then
checklist := ts.tablespace_name; else
checklist := checklist||','||ts.tablespace_name; end if;
i := 1;
end loop; dbms_tts.transport_set_check(checklist,TRUE,TRUE);
end;
/
select * from transport_set_violations;

 
tts_system_user_obj.sql is a sample script to identify user owned objects in the SYSTEM or SYSAUX tablespaces.

tts_verify.sql is a sample script to compare segment, object, and invalid object counts between the source and target databases.

tts_system_user_obj.sql
select owner, segment_name, segment_type from dba_segments
where tablespace_name in ('SYSTEM', 'SYSAUX') and owner not in
(select name
from system.logstdby$skip_support where action=0)
;

tts_verify.sql
REM
REM Script to compare segment, object, and invalid object counts REM between two databases. This script should be run on the target REM database.
REM
REM This script requires a database link named ttslink between the REM source and target databases.
REM

set heading off feedback off trimspool on linesize 500 spool tts_verify.out
prompt
prompt Segment count comparison across dblink prompt
select r.owner, r.segment_type, r.remote_cnt Source_Cnt, l.local_cnt Target_Cnt
from ( select owner, segment_type, count(owner) remote_cnt from dba_segments@ttslink
where owner not in (select name
from system.logstdby$skip_support
where action=0)    group by owner, segment_type ) r
, ( select owner, segment_type, count(owner) local_cnt from dba_segments
where owner not in (select name
from system.logstdby$skip_support
where action=0)    group by owner, segment_type ) l where l.owner (+) = r.owner
and l.segment_type (+) = r.segment_type and nvl(l.local_cnt,-1) != r.remote_cnt
order by 1, 3 desc
/

prompt
prompt Object count comparison across dblink prompt
select r.owner, r.object_type, r.remote_cnt Source_Cnt, l.local_cnt Target_Cnt
from ( select owner, object_type, count(owner) remote_cnt from dba_objects@ttslink
where owner not in (select name
from system.logstdby$skip_support
where action=0)    group by owner, object_type ) r
, ( select owner, object_type, count(owner) local_cnt from dba_objects
where owner not in (select name
from system.logstdby$skip_support
where action=0)    group by owner, object_type ) l where l.owner (+) = r.owner
and l.object_type (+) = r.object_type and nvl(l.local_cnt,-1) != r.remote_cnt
order by 1, 3 desc
/

prompt
prompt Invalid object count comparison across dblink prompt
select l.owner, l.object_type, r.remote_cnt Source_Cnt, l.local_cnt Target_Cnt
from ( select owner, object_type, count(owner) remote_cnt from dba_objects@ttslink
where owner not in (select name
from system.logstdby$skip_support
where action=0)    and status='INVALID' group by owner, object_type ) r
, ( select owner, object_type, count(owner) local_cnt from dba_objects
where owner not in (select name
from system.logstdby$skip_support
where action=0)    and status='INVALID' group by owner, object_type ) l
where l.owner = r.owner (+)
and l.object_type = r.object_type (+) and l.local_cnt != nvl(r.remote_cnt,-1)
order by 1, 3 desc
/

spool off
 

 

你可能感兴趣的:(oracle)