Here is the shell script to do de-fragmentation activities for a table in Oracle database.
You can feed the table name and schema name and run this script in back ground
#!/bin/ksh
export ORACLE_HOME=/oracle/TESTDB5/1924
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=TESTDB5
TMP_LOG=/oracle/scripts/logs/trans_table_redef.log
echo > $TMP_LOG
sqlplus -s /nolog <<EOF >> $TMP_LOG
whenever sqlerror exit 1
conn / as sysdba
SET SERVEROUTPUT ON;
ALTER SESSION FORCE PARALLEL DML PARALLEL 2;
ALTER SESSION FORCE PARALLEL QUERY PARALLEL 2;
exec DBMS_REDEFINITION.CAN_REDEF_TABLE('<schema_name>','<Table_name>', DBMS_REDEFINITION.CONS_USE_ROWID);
exit
EOF
# Check if SQL execution was successful
if [ $? -eq 0 ]; then
SUBJECT="Table Redefinition Completed Successfully"
else
SUBJECT="Table Redefinition Failed"
fi
# Send the log file via email
mailx -s "$SUBJECT" Balamani@abc.com < $TMP_LOG
No comments:
Post a Comment