Oracle删除表空间的shell脚本代码
#!/bin/bash
#ocpyang@126.com
#drop tablespace
if [ $# -ne 1 ]; then
echo "Usage: $0 TABLESPACE_NAME "
exit 1
fi
#configure oracle env:about oracle envs, username and password
ORACLE_SID=orcl
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ora_data=/u01/app/oracle/product/11.2.0/db_1/dbs/
ora_user="sys" #oracle username
ora_pass="password" #oracle user password
tablespace_name=$(echo $1 | tr '[a-z]' '[A-Z]')
outfiletmp=/tmp/droptpstmp01.txt #specify the output file location
sqlplus -S "${ora_user}/${ora_pass} as sysdba" set heading off;
set feedback off;
set termout off;
set pagesize 0;
set verify off;
set echo off;
spool ${outfiletmp}
select tablespace_name from dba_tablespaces where tablespace_name='${tablespace_name}';
spool off
exit;
!01
tps_jug=`grep -i ${tablespace_name} ${outfiletmp} `
if [ "${tps_jug}" = "${tablespace_name}" ]; then
wind_var=$(
sqlplus -s "{ora_user}/${ora_pass} as sysdba"