Shell Script to Resize Temp File


In this post, I am going to share a shell script to resize temporary tablespace. Mostly after the database base clone we might need to reduce the size of the temp files.
You can incorporate this in any other post-clone scripts or as required. I have done it using functions in the shell script.


cat resize.sh

#!/bin/bash
fun_temp_resize()
{
sqlplus -s '/as sysdba' << EOF > /tmp/tempfile_number
set head off
select file_id from dba_temp_files;
EOF
for i in `cat /tmp/tempfile_number`
do
echo "alter database tempfile ${i} resize 10g;"
done >/tmp/temp_resize.sql
}

#####Main Program Call#####

sqlplus /nolog << EOF   2>&1 | tee -a  $LOGFILE
connect / as sysdba
@/tmp/temp_resize.sql
EOF






If you like please follow and comment