A data validation framework for 10g with ORA_HASH

advertisement
-- parameter table for validation
create table thash_params (
vsegment_owner varchar2(64),
vsegment_name varchar2(64),
vpartition_name varchar2(64),
ngroup number(3),
norder number(3),
tot_bytes number,
vhash_sql clob,
nhash_result binary_double, -- 10g
ncnt_result binary_double, -- 10g
dstart timestamp,
dstop timestamp,
nsql_code number,
vsql_errm varchar2(512))
PCTFREE 30 PCTUSED 65 INITRANS 37 MAXTRANS 255
STORAGE ( INITIAL 100K NEXT 100K MINEXTENTS 5 MAXEXTENTS
512 PCTINCREASE 0 FREELISTS 37) ;
create unique index pk_owner_name on THASH_PARAMS (VSEGMENT_OWNER,
VSEGMENT_NAME, vpartition_name)
PCTFREE 30 INITRANS 37 MAXTRANS 255
STORAGE ( INITIAL 100K NEXT 100K MINEXTENTS 5 MAXEXTENTS
512 PCTINCREASE 0 FREELISTS 37) ;
/* demo purpose params and initial data type controls
INSERT INTO thash_params
(vsegment_owner, vsegment_name)
SELECT a.owner, a.table_name
FROM dba_tables a
WHERE a.owner NOT IN ('SYS', 'SYSTEM');
DELETE FROM thash_params aa
WHERE aa.vsegment_owner || aa.vsegment_name IN
(SELECT c.owner || c.table_name
FROM thash_params a,
(SELECT DISTINCT b.owner, b.table_name
FROM dba_tab_columns b -- 10g @gg_valid
WHERE b.data_type NOT IN ('CHAR', 'DATE', 'FLOAT',
'NUMBER', 'VARCHAR2')) c
WHERE a.vsegment_owner = c.owner
AND a.vsegment_name = c.table_name);
commit;
*/
-- after loading params gather stats and control the params
begin
dbms_stats.gather_table_stats(user, tabname => 'thash_params', cascade
=> TRUE);
end;
/
commit;
select count(*) from thash_params ;
-- the procedure to create the validation scripts on unix
/*
mkdir /tmp/gg_valid_bscs
chmod 777 /tmp/gg_*
create user gg_valid_bscs identified by gg default tablespace ..
temporary tablespace .. ;
grant connect, resource, select_catalog_role, imp_full_database,
unlimited tablespace to gg_valid_bscs ;
grant alter session, query rewrite, debug connect session, create
database link to gg_valid_bscs;
grant select on v_$system_parameter to gg_valid_bscs ;
grant select on dba_segments to gg_valid_bscs ;
grant select on dba_tab_columns to gg_valid_bscs ;
CREATE OR REPLACE DIRECTORY sql_dir AS '/tmp/gg_valid_bscs';
*/
CREATE OR REPLACE PROCEDURE prc_hash_them_all(nparallelism PLS_INTEGER,
vuser_name
VARCHAR2,
vpasswd
VARCHAR2) IS
ncpu_count
NUMBER(3) := 1;
ngrouping
NUMBER(3) := 1;
v_col_str
VARCHAR2(32767) := '';
vhash_sql_str
VARCHAR2(32767) := '';
vdir_loc
VARCHAR2(30) := upper('sql_dir');
out_file
utl_file.file_type;
ncol_counter
NUMBER(4) := 1;
nparallelism_real PLS_INTEGER;
BEGIN
SELECT
INTO
FROM
WHERE
VALUE
ncpu_count
v$system_parameter b -- 10g @gg_valid
b.NAME LIKE 'cpu_count';
ngrouping := trunc(ncpu_count / nparallelism);
IF ngrouping < 1 THEN
ngrouping := 1;
END IF;
FOR cur_grouping IN (SELECT y.owner,
y.segment_name,
y.partition_name,
y.group#,
y.tot_bytes,
dense_rank() over(PARTITION BY group#
ORDER BY tot_bytes DESC) AS order#
FROM (SELECT x.*,
MOD(rownum,
ngrouping) group#
FROM (SELECT owner,
segment_name,
partition_name,
SUM(a.bytes) tot_bytes
FROM dba_segments a,
thash_params b -- 10g @gg_valid
WHERE a.segment_name =
b.vsegment_name
AND a.owner = b.vsegment_owner
AND a.partition_name =
b.vpartition_name
AND b.vpartition_name IS NOT
NULL
GROUP BY owner, segment_name,
partition_name
UNION ALL
SELECT owner,
segment_name,
partition_name,
SUM(a.bytes) tot_bytes
FROM dba_segments a,
thash_params b -- 10g @gg_valid
WHERE a.segment_name =
b.vsegment_name
AND a.owner = b.vsegment_owner
AND b.vpartition_name IS NULL
GROUP BY owner, segment_name,
partition_name
ORDER BY tot_bytes DESC) x) y
ORDER BY group#, order#) LOOP
IF cur_grouping.partition_name IS NOT NULL THEN
UPDATE thash_params t
SET t.ngroup
= cur_grouping.group#,
t.norder
= cur_grouping.order#,
t.tot_bytes
= cur_grouping.tot_bytes,
t.ncnt_result = NULL,
t.nhash_result = NULL
WHERE t.vsegment_name = cur_grouping.segment_name
AND t.vsegment_owner = cur_grouping.owner
AND t.vpartition_name = cur_grouping.partition_name;
ELSE
UPDATE thash_params t
SET t.ngroup
= cur_grouping.group#,
t.norder
= cur_grouping.order#,
t.tot_bytes
= cur_grouping.tot_bytes,
t.ncnt_result = NULL,
t.nhash_result = NULL
WHERE t.vsegment_name = cur_grouping.segment_name
AND t.vsegment_owner = cur_grouping.owner;
END IF;
END LOOP;
FOR cur_hash_sql1 IN (SELECT vsegment_owner owner,
vsegment_name tabname,
vpartition_name part_name,
norder
FROM thash_params
WHERE ngroup IS NOT NULL) LOOP
ncol_counter := 0;
FOR cur_hash_sql2 IN (SELECT column_name
FROM dba_tab_columns -- 10g @gg_valid
WHERE table_name = cur_hash_sql1.tabname
AND owner = cur_hash_sql1.owner
ORDER BY column_name) LOOP
v_col_str
:= v_col_str || cur_hash_sql2.column_name || '||';
ncol_counter := ncol_counter + 1;
IF MOD(ncol_counter,
25) = 0 THEN
v_col_str := v_col_str || chr(10);
END IF;
END LOOP;
IF MOD(ncol_counter,
25) = 0 THEN
v_col_str := substr(v_col_str,
1,
length(v_col_str) - 3);
ELSE
v_col_str := substr(v_col_str,
1,
length(v_col_str) - 2);
END IF;
IF cur_hash_sql1.part_name IS NULL THEN
-- 10g
IF cur_hash_sql1.norder = 1 THEN
nparallelism_real := nparallelism * 2;
ELSE
nparallelism_real := nparallelism;
END IF;
vhash_sql_str := 'DECLARE nhash thash_params.nhash_result%TYPE;
ncnt thash_params.ncnt_result%TYPE; vsqlerrm thash_params.vsql_errm%TYPE;
nsqlcode thash_params.nsql_code%TYPE; wdstop thash_params.dstop%TYPE;
wnhash_result thash_params.nhash_result%TYPE; wncnt_result
thash_params.ncnt_result%TYPE; BEGIN SELECT dstop, nhash_result,
ncnt_result INTO wdstop, wnhash_result, wncnt_result FROM thash_params
WHERE vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname ||
'''; IF (wdstop IS NULL OR wnhash_result IS
NULL OR wncnt_result IS NULL) THEN update thash_params set dstart =
current_timestamp, DSTOP = NULL, NSQL_CODE = NULL, VSQL_ERRM = NULL where
vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname ||
''' ; commit; select /*+ full(t) parallel(t,'
|| nparallelism_real ||
') */ count(*), sum(ora_hash(' || v_col_str ||
', 4294967294)) into ncnt, nhash from ' ||
cur_hash_sql1.owner || '.' ||
cur_hash_sql1.tabname ||
' t ; update thash_params set dstop =
current_timestamp, nhash_result = nhash, ncnt_result = ncnt where
vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname ||
''' ; commit; END IF; exception when others
then vsqlerrm := SQLERRM; nsqlcode := SQLCODE; update thash_params set
nsql_code = nsqlcode, vsql_errm = vsqlerrm where vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname || ''' ; commit; end; ';
UPDATE thash_params t
SET t.vhash_sql = vhash_sql_str
WHERE t.vsegment_name = cur_hash_sql1.tabname
AND t.vsegment_owner = cur_hash_sql1.owner;
ELSE
-- 10g
IF cur_hash_sql1.norder = 1 THEN
nparallelism_real := nparallelism * 2;
ELSE
nparallelism_real := nparallelism;
END IF;
vhash_sql_str := 'DECLARE nhash thash_params.nhash_result%TYPE;
ncnt thash_params.ncnt_result%TYPE; vsqlerrm thash_params.vsql_errm%TYPE;
nsqlcode thash_params.nsql_code%TYPE; wdstop thash_params.dstop%TYPE;
wnhash_result thash_params.nhash_result%TYPE; wncnt_result
thash_params.ncnt_result%TYPE; BEGIN SELECT dstop, nhash_result,
ncnt_result INTO wdstop, wnhash_result, wncnt_result FROM thash_params
WHERE vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname || ''' and
vpartition_name = ''' ||
cur_hash_sql1.part_name ||
'''; IF (wdstop IS NULL OR wnhash_result IS
NULL OR wncnt_result IS NULL) THEN update thash_params set dstart =
current_timestamp, DSTOP = NULL, NSQL_CODE = NULL, VSQL_ERRM = NULL where
vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname || ''' and
vpartition_name = ''' ||
cur_hash_sql1.part_name ||
''' ; commit; select /*+ full(t) parallel(t,'
|| nparallelism_real ||
') */ count(*), sum(ora_hash(' || v_col_str ||
', 4294967294)) into ncnt, nhash from ' ||
cur_hash_sql1.owner || '.' ||
cur_hash_sql1.tabname ||
' PARTITION(' || cur_hash_sql1.part_name ||
') t ; update thash_params set dstop =
current_timestamp, nhash_result = nhash, ncnt_result = ncnt where
vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname || ''' and
vpartition_name = ''' ||
cur_hash_sql1.part_name ||
''' ; commit; END IF; exception when others
then vsqlerrm := SQLERRM; nsqlcode := SQLCODE; update thash_params set
nsql_code = nsqlcode, vsql_errm = vsqlerrm where vsegment_owner = ''' ||
cur_hash_sql1.owner || ''' and vsegment_name =
''' ||
cur_hash_sql1.tabname || ''' and
vpartition_name = ''' ||
cur_hash_sql1.part_name || ''' ; commit; end;
';
UPDATE
SET
WHERE
AND
AND
END IF;
thash_params t
t.vhash_sql = vhash_sql_str
t.vsegment_name = cur_hash_sql1.tabname
t.vsegment_owner = cur_hash_sql1.owner
t.vpartition_name = cur_hash_sql1.part_name;
v_col_str
:= '';
vhash_sql_str := '';
END LOOP;
FOR cur_file_single IN (SELECT ngroup,
norder,
tt.vhash_sql,
tt.vsegment_owner,
tt.vsegment_name,
tt.vpartition_name,
lag(ngroup,
1,
-1) over(ORDER BY ngroup, norder)
AS prev_ngroup
FROM thash_params tt
WHERE norder = 1
ORDER BY ngroup, norder) LOOP
IF cur_file_single.ngroup <> cur_file_single.prev_ngroup THEN
IF utl_file.is_open(out_file) THEN
utl_file.put_line(out_file,
'END;');
utl_file.put_line(out_file,
'/');
utl_file.put_line(out_file,
'spool off');
utl_file.put_line(out_file,
'exit;');
utl_file.fclose(out_file);
END IF;
out_file := utl_file.fopen(vdir_loc,
'single' || cur_file_single.ngroup ||
'.sql',
'w',
32767);
utl_file.put_line(out_file,
'set timing on;');
utl_file.put_line(out_file,
'set serveroutput on;');
utl_file.put_line(out_file,
'alter session enable parallel dml;');
utl_file.put_line(out_file,
'alter session enable parallel ddl;');
utl_file.put_line(out_file,
'alter session set
nls_date_format=''DD.MM.YYYY HH24:MI:SS'';');
utl_file.put_line(out_file,
'spool ' || 'single' || cur_file_single.ngroup
|| '.lst');
utl_file.put_line(out_file,
'BEGIN');
END IF;
DECLARE
l_amt
NUMBER DEFAULT 32767;
l_offset NUMBER DEFAULT 1;
l_length NUMBER DEFAULT NULL;
BEGIN
l_length := nvl(dbms_lob.getlength(cur_file_single.vhash_sql),
0);
IF l_length > l_amt THEN
WHILE (l_offset < l_length) LOOP
utl_file.put(out_file,
dbms_lob.substr(cur_file_single.vhash_sql,
l_amt,
l_offset));
utl_file.fflush(out_file);
l_offset := l_offset + l_amt;
END LOOP;
utl_file.new_line(out_file);
ELSE
utl_file.put_line(out_file,
cur_file_single.vhash_sql);
END IF;
/*
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('hata : ' || SQLERRM);
dbms_output.put_line('length : ' || l_length);
dbms_output.put_line(cur_file_single.vsegment_owner || '-' ||
cur_file_single.vsegment_name); */
END;
END LOOP;
IF utl_file.is_open(out_file) THEN
utl_file.put_line(out_file,
'END;');
utl_file.put_line(out_file,
'/');
utl_file.put_line(out_file,
'spool off');
utl_file.put_line(out_file,
'exit;');
utl_file.fclose(out_file);
END IF;
FOR cur_file IN (SELECT ngroup,
norder,
tt.vhash_sql,
tt.vsegment_owner,
tt.vsegment_name,
tt.vpartition_name,
lag(ngroup,
1,
-1) over(ORDER BY ngroup, norder) AS
prev_ngroup
FROM thash_params tt
WHERE ngroup IS NOT NULL
AND norder <> 1
ORDER BY ngroup, norder) LOOP
IF cur_file.ngroup <> cur_file.prev_ngroup THEN
IF utl_file.is_open(out_file) THEN
utl_file.put_line(out_file,
'END;');
utl_file.put_line(out_file,
'/');
utl_file.put_line(out_file,
'spool off');
utl_file.put_line(out_file,
'exit;');
utl_file.fclose(out_file);
END IF;
out_file := utl_file.fopen(vdir_loc,
'group' || cur_file.ngroup || '.sql',
'w',
32767);
utl_file.put_line(out_file,
'set timing on;');
utl_file.put_line(out_file,
'set serveroutput on;');
utl_file.put_line(out_file,
'alter session enable parallel dml;');
utl_file.put_line(out_file,
'alter session enable parallel ddl;');
utl_file.put_line(out_file,
'alter session set
nls_date_format=''DD.MM.YYYY HH24:MI:SS'';');
utl_file.put_line(out_file,
'spool ' || 'group' || cur_file.ngroup ||
'.lst');
utl_file.put_line(out_file,
'BEGIN');
END IF;
DECLARE
l_amt
l_offset
l_length
BEGIN
l_length
NUMBER DEFAULT 32767;
NUMBER DEFAULT 1;
NUMBER DEFAULT NULL;
:= nvl(dbms_lob.getlength(cur_file.vhash_sql),
0);
IF l_length > l_amt THEN
WHILE (l_offset < l_length) LOOP
utl_file.put(out_file,
dbms_lob.substr(cur_file.vhash_sql,
l_amt,
l_offset));
utl_file.fflush(out_file);
l_offset := l_offset + l_amt;
END LOOP;
utl_file.new_line(out_file);
ELSE
utl_file.put_line(out_file,
cur_file.vhash_sql);
END IF;
/*
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('hata : ' || SQLERRM);
dbms_output.put_line('length : ' || l_length);
dbms_output.put_line(cur_file.vsegment_owner || '-' ||
cur_file.vsegment_name); */
END;
END LOOP;
IF utl_file.is_open(out_file) THEN
utl_file.put_line(out_file,
'END;');
utl_file.put_line(out_file,
'/');
utl_file.put_line(out_file,
'spool off');
utl_file.put_line(out_file,
'exit;');
utl_file.fclose(out_file);
END IF;
out_file := utl_file.fopen(vdir_loc,
'grant_all.sql',
'w');
FOR cur_grant IN (SELECT DISTINCT vsegment_owner, vsegment_name FROM
thash_params tt) LOOP
utl_file.put_line(out_file,
'grant select on ' || cur_grant.vsegment_owner ||
'.' ||
cur_grant.vsegment_name || ' to ' || vuser_name
|| ' ;');
END LOOP;
utl_file.put_line(out_file,
'exit;');
utl_file.fclose(out_file);
out_file := utl_file.fopen(vdir_loc,
'hash_them_all.sh',
'w');
utl_file.put_line(out_file,
'# nohup sqlplus ' || vuser_name || '/' || vpasswd
||
' @grant_all.sql > grant_all.log 2> grant_all.err');
FOR cur_shell_single IN (SELECT DISTINCT ngroup
FROM thash_params tt
WHERE ngroup IS NOT NULL) LOOP
utl_file.put_line(out_file,
'nohup sqlplus ' || vuser_name || '/' || vpasswd
|| ' @single' ||
cur_shell_single.ngroup || '.sql > single' ||
cur_shell_single.ngroup || '.log 2> single' ||
cur_shell_single.ngroup || '.err &');
END LOOP;
FOR cur_shell_script IN (SELECT DISTINCT ngroup
FROM thash_params tt
WHERE ngroup IS NOT NULL) LOOP
utl_file.put_line(out_file,
'nohup sqlplus ' || vuser_name || '/' || vpasswd
|| ' @group' ||
cur_shell_script.ngroup || '.sql > group' ||
cur_shell_script.ngroup || '.log 2> group' ||
cur_shell_script.ngroup || '.err &');
END LOOP;
utl_file.fclose(out_file);
END prc_hash_them_all;
/
-- execute the procedure and control the outputs before running shell
scripts produced
begin
prc_hash_them_all(nparallelism => 4,
vuser_name => 'gg_valid_ths',
vpasswd => 'bla_bla');
end;
/
commit ;
select * from thash_params order by ngroup, norder ;
-- below is a sample output of the script
--- nohup sqlplus gg_valid_ths/bla_bla @demo_ora_hash_10g.sql >
demo_ora_hash_10g.log 2> demo_ora_hash_10g.err &
-set timing on;
set serveroutput on;
alter session enable parallel dml;
alter session enable parallel ddl;
alter session set nls_date_format='DD.MM.YYYY HH24:MI:SS';
spool demo_ora_hash_10g.lst
BEGIN
DECLARE
nhash
thash_params.nhash_result%TYPE;
ncnt
thash_params.ncnt_result%TYPE;
vsqlerrm
thash_params.vsql_errm%TYPE;
nsqlcode
thash_params.nsql_code%TYPE;
wdstop
thash_params.dstop%TYPE;
wnhash_result thash_params.nhash_result%TYPE;
wncnt_result thash_params.ncnt_result%TYPE;
BEGIN
SELECT dstop, nhash_result, ncnt_result
INTO wdstop, wnhash_result, wncnt_result
FROM thash_params
WHERE vsegment_owner = 'SYSADM'
AND vsegment_name = 'ORDERTRAILER_TAX_ITEMS'
AND vpartition_name = 'ORDERTRAILER_TAX_ITEMS_P63';
IF (wdstop IS NULL OR wnhash_result IS NULL OR wncnt_result IS
NULL) THEN
UPDATE thash_params
SET dstart
= current_timestamp,
dstop
= NULL,
nsql_code = NULL,
vsql_errm = NULL
WHERE vsegment_owner = 'SYSADM'
AND vsegment_name = 'ORDERTRAILER_TAX_ITEMS'
AND vpartition_name = 'ORDERTRAILER_TAX_ITEMS_P63';
COMMIT;
SELECT /*+ full(t) parallel(t,8) */
COUNT(*),
SUM(ora_hash(oti_seqno || otseq || otxact || rec_version ||
taxcode ||
tax_exempted || tax_seqno,
4294967294))
INTO ncnt, nhash
FROM sysadm.ordertrailer_tax_items
PARTITION(ordertrailer_tax_items_p63) t;
UPDATE thash_params
SET dstop = current_timestamp, nhash_result = nhash,
ncnt_result = ncnt
WHERE vsegment_owner = 'SYSADM'
AND vsegment_name = 'ORDERTRAILER_TAX_ITEMS'
AND vpartition_name = 'ORDERTRAILER_TAX_ITEMS_P63';
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
vsqlerrm := SQLERRM;
nsqlcode := SQLCODE;
UPDATE thash_params
SET nsql_code = nsqlcode, vsql_errm = vsqlerrm
WHERE vsegment_owner = 'SYSADM'
AND vsegment_name = 'ORDERTRAILER_TAX_ITEMS'
AND vpartition_name = 'ORDERTRAILER_TAX_ITEMS_P63';
COMMIT;
END;
END;
/
spool off
exit;
-- post validation controls
SELECT COUNT(*) b_cnt
FROM thash_params b
WHERE b.ncnt_result > 0 and b.ncnt_result is not null and b.nsql_code is
null ;
drop database link gg_check ;
create database link gg_check connect to gg_valid_ths identified by gg
using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST
= 1.1.1.1)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = 10gdb)))';
select * from global_name@gg_check ;
SELECT COUNT(*) a_cnt
FROM thash_params@gg_check a
WHERE a.ncnt_result > 0 and a.ncnt_result is not null and a.nsql_code is
null ;
SELECT
FROM
WHERE
AND
AND
AND
AND
AND
AND
AND
AND
AND
COUNT(*) insersect_cnt
thash_params a, thash_params@gg_check b
a.vsegment_owner = b.vsegment_owner
a.vsegment_name = b.vsegment_name
a.nhash_result = b.nhash_result
a.ncnt_result = b.ncnt_result
a.nsql_code is null
b.nsql_code is null
a.ncnt_result is not null
b.ncnt_result is not null
a.ncnt_result > 0
b.ncnt_result > 0;
SELECT RESULT, COUNT(*)
FROM (SELECT a.vsegment_owner,
a.vsegment_name, a.vpartition_name,
a.tot_bytes,
a.ncnt_result a_ncnt_result,
b.ncnt_result b_ncnt_result,
a.nhash_result a_nhash_result,
b.nhash_result b_nhash_result,
CASE
WHEN a.nhash_result = b.nhash_result THEN
'EQUAL'
FROM
WHERE
AND
AND
ELSE
'NOT-EQUAL'
END "RESULT"
thash_params a, thash_params@gg_check b
a.vsegment_owner = b.vsegment_owner
a.vsegment_name = b.vsegment_name
nvl(a.vpartition_name, 'NULL') = nvl(b.vpartition_name,
'NULL')
AND a.ncnt_result = b.ncnt_result
AND a.nsql_code IS NULL
AND b.nsql_code IS NULL
AND a.ncnt_result IS NOT NULL
AND b.ncnt_result IS NOT NULL
AND a.ncnt_result > 0
AND b.ncnt_result > 0)
GROUP BY RESULT;
SELECT a.vsegment_owner,
a.vsegment_name,
a.tot_bytes,
a.ncnt_result,
a.nsql_code a_nsql_code,
a.vsql_errm a_vsql_errm,
b.nsql_code b_nsql_code,
b.vsql_errm b_vsql_errm
FROM thash_params a, thash_params@gg_check b
WHERE a.vsegment_owner = b.vsegment_owner
AND a.vsegment_name = b.vsegment_name
AND (a.nsql_code IS NOT NULL OR b.nsql_code IS NOT NULL) ;
create database link gg_source connect to gg_valid_ths identified by
gg
using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.1)(PORT
= 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = 10gdb)
(INSTANCE_NAME = 10gdb)))';
select * from global_name@gg_source ;
create database link gg_target connect to gg_valid_ths identified by
gg
using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 2.2.2.2)(PORT
= 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = 10gdb)
(INSTANCE_NAME = 10gdb)))';
select * from global_name@gg_target ;
create table TMNS1_REPLICA_SDP_DED_MRT pctfree 1 pctused 99 nologging
parallel 8 as
select /*+ parallel(t1,8) */ * from REPLICA.SDP_DED_MRT@gg_source t1
minus
select /*+ parallel(t2,8) */ * from REPLICA.SDP_DED_MRT@gg_target t2 ;
create table TMNS2_REPLICA_SDP_DED_MRT pctfree 1 pctused 99 nologging
parallel 8 as
select /*+ parallel(t1,8) */ * from REPLICA.SDP_DED_MRT@gg_target t1
minus
select /*+ parallel(t2,8) */ * from REPLICA.SDP_DED_MRT@gg_source t2 ;
-- to clean up
drop PROCEDURE prc_hash_them_all;
drop table thash_params purge ; -- 10g
Download