• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Oracle删除表空间的shell脚本实例

mysql 搞代码 4年前 (2022-01-09) 20次浏览 已收录 0个评论

Oracle删除表空间的shell脚本代码 #!/bin/bash#[email protected]#drop tablespace if [ $# -ne 1 ]; then echo Usage: $0 TABLE

Oracle删除表空间的shell脚本代码

#!/bin/bash
#[email protected]
#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” </dev/null #禁止sqlplus执行结果回显
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” <<EOF
set heading off
drop tablespace ${tablespace_name} including contents a本文来源gaodaimacom搞#^代%!码&网(nd datafiles;
EXIT;
EOF)
echo -e “\e[1;32m ${wind_var} \e[0m” #Direct display returns results
rm -rf ${outfiletmp}
exit 1
else
echo -e “\e[1;31m ————————————— \e[0m”
echo -e “\e[1;31m The tablespace ${tablespace_name} not exits! \e[0m”
echo -e “\e[1;31m ————————————— \e[0m”
rm -rf ${outfiletmp}
exit 1

fi

Oracle 11g 在RedHat Linux 5.8_x64平台的安装手册

Linux-6-64下安装Oracle 12C笔记

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

本文永久更新链接地址:


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Oracle删除表空间的shell脚本实例

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址