giovedì 16 agosto 2012

index rebuild oracle crontab - beta

Still BETA


#!/bin/bash
 
##function
check_id_oracle() {
whoami | grep oracle > /dev/null
if [[ "$?" -eq 0 ]]
then
echo "good - you are oracle"
else
echo "you must be oracle"
exit 1
fi
}
 
 
check_be_active() {
ps -ef | grep "[/j]boss-4.2.3GA" > /dev/null
if [[ "$?" -eq 0 ]]
then
echo "good - be active"
else
echo "be stand by"
exit 1
fi
}
 
. .profile
check_id_oracle
check_be_active
v_schema=INEM_REP
sqlplus -s INEM_REP/INEM_REP@XE <<-EOF 2>&1 > /dev/null
set head off
set linesize 60
spool /tmp/rebuild_idx_${v_schema}.sql
select 'spool /tmp/rebuild_idx_${v_schema}.log' from dual;
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='ITEMCONFIG' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='SINGLE_VALUE_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='STRUCT_VALUE_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='MULTI_VALUE_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='VALUES_MV_ATTRIBUTES' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='VALUES_STRUCT_ATTRIBUTES' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_ENTITY_NODE_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_NODE_INTERFACE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_NODE_INTERFACE_CREDENTIALS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_TO_NGN_NODE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_DOMAINS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_INTERFACE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_INTERFACE_CREDENTIALS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_INTER_CRED_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_MV_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_VALUES_MV_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='LOGICAL_AGGREGATION' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_ENTITY_NODE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_LOGICAL_AGGREGATION' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_REQUIRED_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_LOGICAL_CONFIGURATION' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_ATTR' and INDEX_TYPE='NORMAL';
 
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_OTHER_NODE_IP_TYPE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_REQUIRED_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_PROTOCOLS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_CREDENTIAL_ATTRIBUTES' and INDEX_TYPE='NORMAL';
spool off
@/tmp/rebuild_idx_${v_schema}.sql
exit;
EOF
echo "done"
echo "logs index under /tmp/rebuild_idx_INEM_REP.log"

Nessun commento:

Posta un commento