Splitter Hint
Splitter Hint
begin
if dir is not null then
use_dir := dir;
end if;
select count (*)
into cnt
from all_directories
where directory_name = use_dir;
if cnt = 0 then
raise_application_error (-20010, 'The directory ' || use_dir || ' needs to be
created!');
end if;
end;
WHR_file := UTL_FILE.FOPEN(use_dir,
translate (upper (tab_name), '/', '_') || '-' ||
num_pack || '.WHR', 'W');
-- Output of Hint
create_hint (WHR_file, tab_name, 'ROWID', 'ROWID');
utl_file.fclose (WHR_file);
end;
WHR_file := UTL_FILE.FOPEN(use_dir,
translate (upper (tab_name), '/', '_') || '-' ||
num_pack || '.WHR', 'W');
for i in range.first..range.last loop
if (range.exists(i) and range(i) is not null) then
utl_file.put_line (WHR_file, 'tab: ' || tab_name);
utl_file.put_line (WHR_file, range(i));
-- Output of Hint
create_hint (WHR_file, tab_name, col_name, split_type);
utl_file.fclose (WHR_file);
end;
WHR_file := UTL_FILE.FOPEN(use_dir,
translate (upper (tab_name), '/', '_') || '-' ||
num_pack || '.WHR', 'W');
else
if low_range != 'MAXVALUE' then
range := 'WHERE ("' || col_name || '" >= ''' || low_range || ''')';
end if;
end if;
utl_file.fclose (WHR_file);
end;
begin
open curs2 for 'select /*+ full(t) parallel (t) */ "' || col_name || '", sum
(pagelg) pagelg, count (*) cnt
from "' || tab_name || '" t group by "' || col_name || '" order
by "' || col_name || '"';
loop
end if;
end loop;
end loop;
close curs2;
begin
open curs2 for 'select /*+ full (t) parallel (t) */ "' || col_name || '", count
(*) cnt
from "' || tab_name || '" t group by "' || col_name || '" order
by "' || col_name || '"';
loop
pack_no := pack_no + 1;
ins_ranges (first_range, false,
tab_name, col_name,
low_range, high_range,
0, 0,
sum_recs, tot_recs, pack_no, num_packages, 'TRANSPARENT');
end loop;
end loop;
close curs2;
end; /* end of ranges_tp */
begin
select column_name
into col_name
from USER_PART_KEY_COLUMNS
where name = tab_name
and object_type = 'TABLE';
parts := parttypearr();
parts.extend (1);
parts (rec.partition_position).cnt := recs_part;
if substr (rec.high_value, 1, 1) = '''' then
parts (rec.partition_position).high_value := ltrim (rtrim (rec.high_value,
''''), '''');
else
parts (rec.partition_position).high_value := rec.high_value;
end if;
end loop;
tot_recs := tot_recs_o / num_packages;
pack_no := pack_no + 1;
ins_ranges (first_range, false,
tab_name, col_name,
low_range, high_range,
0, 0,
sum_recs, tot_recs, pack_no, num_packages, 'PARTITION');
end loop;
cursor sel_ext is
select /*+ OPT_PARAM ( '_optimizer_extended_stats_usage_control' 252) */
relative_fno, block_id, blocks
from sys.dba_extents
where owner = user
and segment_name = tab_name
order by relative_fno, block_id;
begin
select data_object_id
into obj_id
from user_objects
where object_type = 'TABLE'
and object_name = tab_name;
open sel_ext;
loop
pack_no := pack_no + 1;
end_rowid := dbms_rowid.rowid_create (1, obj_id, extents(i).relative_fno,
end loop;
if sum_blocks > 0 then
pack_no := pack_no + 1;
log_message (1, 'Writing last Package ' || pack_no || ' blocks: ' ||
sum_blocks);
log_message (1, 'Range: ' || start_rowid || ' - ' );
ins_ranges_rowid (tab_name, start_rowid, null, pack_no);
end if;
close sel_ext;
log_message (0, 'Identified ' || num_ext || ' extents and wrote ' || pack_no ||
' Packages.');
pagelg_cnt number;
part_cnt number;
cnt number;
-- delete following line for 9.2
start_CPU_time number := dbms_utility.get_cpu_time;
start_time number := dbms_utility.get_time;
num_rows number;
avg_row_len number;
bytes number;
blocks number;
begin
user_error := false;
check_directory (dir);
-- Initialize logging
log_file := UTL_FILE.FOPEN(use_dir,
translate (upper (tab_name), '/', '_') || '.log',
'W');
log_message (0, 'Oracle table splitter Version: ' || splitter_version ||
' at ' || to_char (SYSDATE, 'yyyy.mm.dd hh24:mi:ss'));
log_message (0, 'Connected to:');
for banner_rec in (select banner from v$version) loop
log_message (0, banner_rec.banner);
end loop;
log_message (0, 'Splitting table: ' || tab_name);
log_message (0, 'Using Test Level: ' || test_level);
begin
select num_rows, avg_row_len
into num_rows, avg_row_len
from user_tables
where table_name = tab_name;
exception
when no_data_found then
raise_splitter_error ('Invalid Table Name: ' || tab_name);
end;
log_message (0, 'Rows: ' || num_rows || ' Size: ' || round (bytes/1024/1024) ||
' MB');
-- Check if the table is a clustered table
if cnt = 0 then
raise_splitter_error ('Column name ' || col_name || ' invalid');
end if;
end if;
end if;
commit;
EXCEPTION
WHEN OTHERS THEN
end;
/
show errors