Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Logic Works 04

Logic Works 04

Ratings: (0)|Views: 122|Likes:
Published by jp_vijaykumar
Complex shell and pl/sql scripts
Complex shell and pl/sql scripts

More info:

Published by: jp_vijaykumar on Jul 09, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

08/20/2013

pdf

text

original

 
LOGIC WORKS04AUTHOR JP VIJAYKUMARCASE LOGIC 31*************--SCRIPT TO DROP ALL OBJECTS IN A SCHEMA. PLS EXCERSIZE CAUTION--USE THIS SCRIPT AT YOUR OWN RISK AND RESPONSIBILITY.CASE LOGIC 32*************--I WANT TO SCP LARGE EXPORT DUMP FILES ACROSS THE NETWORK BETWEEN SERVERS.--FOR SOME REASON, OUR SCP CAN NOT SPAWN MORE THAN 10 CONCURRENT SESSION.AFTER 10 CONCURRENT SESSIONS, THE JOB FAILS. THIS IS THE WORK AROUND.CASE LOGIC 33*************--THIS SHELL SCRIPT LOOPS THROUGH ALL THE NODES IN THE CLUSTER AND DOES SOMEHEALTH CHECK AT THE OS LEVEL FOR PERFORMANCE REVIEW.CASE LOGIC 34*************--THIS ONE LINE COMMAND LOOPS THROUGH ALL THE SIDS RUNNING ON A NODE AND EXECUTESSQL SCRIPTS TO CHECK THE HEALTH OF EACH ORACLE DB RUNNING ON A SPECIFIC NODE.CASE LOGIC 35*************--COMBINE CASE LOGIC 23 AND 24 INTO ONE SCRIPT TO LOOP THROUGH EACH NODE AND EACHDB RUNNING ON EACH NODE.CASE LOGIC 36*************--THIS SCRIPT FIND THE YEAR WITH < 365 DAYS. SEPTEMBER MONTH IN 1752 YEAR HADONLY 19 DAYS (11 DAYS LESS THAN A NORMAL SEPTEMBER MONTH)CASE LOGIC 37*************--TO FIND THE ROW COUNTS FROM THE LAST TWO PARTITIONS OF ALL PARTITIONEDTABLES IN A SCHEMA. HERE I AM USING THE MAX PARTITION COUNT, TO FIND # ROWSCASE LOGIC 38*************--TO FIND THE ROW COUNTS FROM THE LAST TWO PARTITIONS OF ALL PARTITIONEDTABLES IN A SCHEMA. HERE I AM USING THE PARTITION_POSITION WITHORDER BY CLAUSE TO FIND NUM_ROWSCASE LOGIC 39*************--HERE IS YOUR HOMEWORK, COMPARE AND CONTRAST SCRIPTS FROM CASE LOGIC 27 AND 28AND FIND OUT THE EFFICIENT SCRIPT WHICH AND WHY.CASE LOGIC 40*************--THE SIZES OF THE DBS ARE GROWING EXPONENTIALLY.TO CUT THE RUN TIMES ON TABLES' STATISTICS GATHERING, I GENERATED THIS SCRIPTTO
 
CAPTURE THE LAST PARTITION OF A RANGE PARTITIONED TABLE WITH DATE RANGE PARTITIONKEY, AND ALL PARTITIONS FOR OTHER TYPES OF PARTITIONS AND NON PARTITIONED TABLES.-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-****************SOLUTION DETAILS*****************************************************-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*CASE LOGIC 31DATE 05-14-11*************--THIS IS A DANGEROUS SCRIPT. PLS EXCERSIZE CAUTION--USE THIS SCRIPT AT YOUR OWN RISK AND RESPONSIBILITYset serverout on size 1000000 timing ondeclarev_ltrchar(1);v_num number;beginexecute immediate 'select substr(name,length(name),1) from v$database' into v_ltr;--OUR PRODUCTION DB NAMES END WITH A "P". THIS SCRIPT WILL NOT WORK IN PRODUCTION DBS.if (v_ltr <> 'P') then<<BEGIN_LOOP>>for c1 in (select object_name,object_type from user_objects order by object_typedesc) loopbeginif (c1.object_type = 'TABLE') thenfor c2 in (select a.table_name,a.constraint_namefrom user_constraints a, user_constraints bwhere a.constraint_type = 'R'and a.r_constraint_name = b.constraint_nameand b.table_name = c1.object_name) loopbeginexecute immediate 'alter table 'c2.table_name' drop constraint 'c2.constraint_name;exceptionwhen others thendbms_output.put_line(c2.table_name' 'c2.constraint_name' 'sqlerrm);end;end loop;end if;--execute immediate 'drop 'c1.object_type' 'c1.object_name; --UNCOMMENT THIS LINE BEFORE EXECUTING THE SCRIPTdbms_output.put_line('drop 'c1.object_type' 'c1.object_name); --COMMENT THIS LINE BEFORE EXECUTING THE SCRIPTexceptionwhen others thendbms_output.put_line(c1.object_name' 'sqlerrm);end;end loop;execute immediate 'select count(1) from user_objects' into v_num;if (v_num > 0) then
 
dbms_output.put_line('Num table: 'v_num);goto BEGIN_LOOP;elsedbms_output.put_line('All objects were dropped');end if;end if;end;/-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*------------------------------------------------------------------------------------CASE LOGIC 32DATE 05-14-11*************--I WANT TO SCP LARGE EXPORT DUMP FILES ACROSS THE NETWORK BETWEEN SERVERS.--FOR SOME REASON, OUR SCP CAN NOT SPAWN MORE THAN 10 CONCURRENT SESSION.AFTER 10 CONCURRENT SESSIONS, THE JOB FAILS. THIS IS THE WORK AROUND.oracle1@linux019:~/scripts/jp> cat parallel_scp.sh#!/bin/kshecho "scp started `date`"export SOURCE_DIR=/apps/oracle2/export/PROD138P/save4qtr#Here provide the file name without the last number and .dmp extention to be scpedexport FILE_NAME=PROD138P_PRODDB_20000421_215959_27168export DEST_HOST=linux020export DEST_DIR=/apps/oracle2/export/PROD018D/save4qtrexport FILE_NUM=0cd $SOURCE_DIRls -1tr $FILE_NAME*while read FNAMEdoecho $FNAME $DEST $DEST_DIRscp $FNAME oracle1@$DEST:$DEST_DIR &echo "scp $FNAME oracle1@$DEST:$DEST_DIR &"FILE_NUM=`expr $FILE_NUM + 1`if [[ $FILE_NUM -eq "8" ]]; thensleep 20;FILE_NUM=0;fidonewaitecho "scp completed `date`"exit-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*CASE LOGIC 33DATE 05-14-11*************--THIS SQL SCRIPT SWITCHES BETWEEN USERS INTERACTIVELY AND PROMPTS FORTHE SCHEMA PASSWORD AND EXECUTES SQL COMMANDS AS THE SCHEMA OWNER.

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->