#!/usr/local/bin/perl # # splitgur, written by Larry Holder, 10-22-98 # # Read gurrddl1.sql (produced by gurrddl.sql) as input, and # write out two sql scripts, with appropriate modifications, # including: # # Make initial and next extents all 1M in size # Change name of spooled logs # Remove /* */ comment lines # Include a DROP table prior to the CREATE table # # Also: create a tablename_exp.par and tablename_imp.par # for exporting and importing the table if needed. # $infile = "gurrddl1.sql"; open (INFILE,"$infile") || die "Oops, can't open $infile: $!\n"; $date_string = `/usr/bin/date +"%D at %T"`; chop($date_string); $found_tname = "N"; $found_spool = "N"; $found_break = "N"; while ($inrec = ) { chop($inrec); if (substr($inrec,0,10) eq "rem table:") { if ($found_tname eq "N") { $found_tname = "Y"; ($w1, $w2, $w3) = split(/ /, $inrec); $tname = $w3; $tname_upper = $tname; $tname =~ tr/A-Z/a-z/; $out1file = $tname . "_sz1.sql"; $out2file = $tname . "_sz2.sql"; open (OUT1,">$out1file") || die "Oops, can't create $out1file: $!\n"; open (OUT2,">$out2file") || die "Oops, can't create $out2file: $!\n"; print OUT1 "rem $out1file generated on $date_string\n"; print OUT1 "rem\n"; print OUT2 "rem $out2file generated on $date_string\n"; print OUT2 "rem\n"; } } else { if (substr($inrec,0,14) eq "rem BREAK HERE") { $found_break = "Y"; print OUT1 "SPOOL OFF\;\n"; print OUT1 "EXIT\;\n"; } else { if (substr($inrec,0,3) ne "rem" and substr($inrec,0,2) ne "/*" and substr($inrec,0,2) ne "*/") { if ($found_spool eq "N") { if (substr($inrec,0,6) eq "SPOOL ") { $found_spool = "Y"; print OUT1 "SPOOL $tname" . "_sz1_\$ORACLE_SID\n"; print OUT2 "SPOOL $tname" . "_sz2_\$ORACLE_SID\n"; } else { print OUT1 "$inrec\n"; print OUT2 "$inrec\n"; } } else { if ($found_break eq "N") { if (substr($inrec,0,12) eq "CREATE TABLE") { ($w1, $w2, $w3) = split(/ /, $inrec); print OUT1 "DROP TABLE $w3\;\n"; print OUT1 "$inrec\n"; } else { if (substr($inrec,0,9) eq "STORAGE (" or substr($inrec,0,8) eq "STORAGE(") { print OUT1 "STORAGE (INITIAL 1M NEXT 1M\n"; } else { print OUT1 "$inrec\n"; } } } else { if (substr($inrec,0,9) eq "STORAGE (" or substr($inrec,0,8) eq "STORAGE(") { print OUT2 "STORAGE (INITIAL 1M NEXT 1M\n"; } else { print OUT2 "$inrec\n"; } } } } } } } close (INFILE); close (OUT1); close (OUT2); print "Split of gurrddl1.sql done for table $tname\n"; $par1file = $tname . "_exp.par"; $par2file = $tname . "_imp.par"; open (PAR1,">$par1file") || die "Oops, can't create $par1file: $!\n"; open (PAR2,">$par2file") || die "Oops, can't create $par2file: $!\n"; print PAR1 "LOG\=$tname" . "_exp_\$ORACLE_SID.log\n"; print PAR1 "FILE\=$tname" . "_\$ORACLE_SID.dmp\n"; print PAR1 "GRANTS\=N\n"; print PAR1 "INDEXES\=N\n"; print PAR1 "CONSTRAINTS\=N\n"; print PAR1 "COMPRESS\=N\n"; print PAR1 "TABLES=(" . $tname_upper . ")\n"; print PAR2 "LOG\=$tname" . "_imp_\$ORACLE_SID.log\n"; print PAR2 "FILE\=$tname" . "_\$ORACLE_SID.dmp\n"; print PAR2 "IGNORE\=Y\n"; print PAR2 "GRANTS\=N\n"; print PAR2 "INDEXES\=N\n"; print PAR2 "COMMIT\=Y\n"; print PAR2 "TABLES=(" . $tname_upper . ")\n"; print "Export and import parm files also generated\n"; exit;