-
Notifications
You must be signed in to change notification settings - Fork 155
/
coalesce.ksh
86 lines (65 loc) · 1.6 KB
/
coalesce.ksh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/ksh
# Script Name : coalesce.ksh
# Author : Craig Richards
# Created : 02-Oct-2002
# Last Modified : 19 March 2003
# Version : 1.1
# Modifications : 19-March-2003 Changed to take out username and password to use OS authentication and removed funct_check_params
# 19-March-2003 Changed so you have to add a SID for the script to run
# Description : This script gets the list of the tablespaces within the database and then coalesces them
#################################
# Start of procedures/functions #
#################################
funct_check_params()
{
if [ ${NARG} -ne 2 ]; then
echo "Not Enough Parameters Passed - Please Supply Username and Password for connection to the database"
exit 1
fi
}
funct_get_tablespace()
{
${ORACLE_HOME}/bin/sqlplus -s / << EOF
SET LINESIZE 200
SET PAUSE OFF
SET HEADING OFF
SET TERMOUT OFF
SET FEEDBACK OFF
SET ECHO OFF
COLUMN tablespace_name FORMAT A30
SPOOL $LOG_FILE
SELECT tablespace_name
FROM dba_tablespaces;
SPOOL OFF
EXIT
EOF
}
funct_coalesce()
{
for NAME in $(cat $LOG_FILE)
do
${ORACLE_HOME}/bin/sqlplus -s / << EOF
ALTER TABLESPACE $NAME COALESCE;
EOF
done
}
################
# Main Program #
################
# Variable Settings
NARG=$#
DBAUSER=$1
DBAPASS=$2
DATE=`date +"%d-%b-%Y"`
LOG_FILE="/admin/output/coalesce.lst"
# Oracle Environment
ORATAB_LOC=/etc/oratab ; export ORATAB_LOC
ORACLE_SID=$2 ; export ORACLE_SID
ORACLE_HOME=`sed /#/d ${ORATAB_LOC} | grep $ORACLE_SID | awk -F: '{print $2}'` ; export ORACLE_HOME
{
touch $LOG_FILE
#funct_check_params
funct_get_tablespace
funct_coalesce >> /admin/output/tblsspc.lst
}
## End of Script