Oracle新建表空间的shell脚本实例

php中文网
发布: 2016-06-07 16:44:56
原创
1483人浏览过

Oracle新建表空间的shell脚本实例代码: #!/bin/bash#ocpyang@126.com#create tablespace if [ $# -ne 2 ]; then echo Usage:

oracle新建表空间的shell脚本实例代码:

#!/bin/bash
#ocpyang@126.com
#create tablespace

if [ $# -ne 2 ]; then
  echo "Usage: $0 TABLESPACE_NAME TABLESPACE_SIZE"
  exit 1
fi

#configure oracle env:about oracle envs, username and password

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

ORACLE_SID=orcl

ora_data=/u01/app/oracle/product/11.2.0/db_1/dbs/


ora_user="sys"

ora_pass="password"


tablespace_name=$(echo $1 | tr '[a-z]' '[A-Z]')

tablespace_size=$2
 
 
outfiletmp01=/tmp/createtpstmp01.txt  #specify the output file location

outfiletmp03=/tmp/createtpstmp03.txt  #specify the output file location

outfiletmp02=/tmp/createtpstmp02.txt  #specify the output file location

 

#check oracle instance is down or up

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 ${outfiletmp01}
select sysdate from dual;
spool off
exit;
!01


ins_jug=`grep -i "ORA-01034:"  ${outfiletmp01} >${outfiletmp02} `
if [ -s ${outfiletmp02} ]; then
 echo -e "\e[1;31m  ******************************************************************  \e[0m"
 echo -e "\e[1;31m  !!!!, oracle IS down!  \e[0m"
 echo -e "\e[1;31m  ******************************************************************  \e[0m"
 rm -rf ${outfiletmp01}
 rm -rf ${outfiletmp02}
 exit 1

fi

 

 

 


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 $outfiletmp03
select tablespace_name from dba_tablespaces where tablespace_name='${tablespace_name}';
spool off
exit;
!01

tps_jug=`grep -i ${tablespace_name} ${outfiletmp03} `

 

if [ "${tps_jug}" = "${tablespace_name}" ]; then   
    echo -e "\e[1;32m  The tablespace ${tablespace_name} exits! \e[0m" 
    rm -rf ${outfiletmp03}
    exit 1 
else
 wind_var=$(
 sqlplus -s "{ora_user}/${ora_pass} as sysdba"  create tablespace ${tablespace_name}
 datafile '${ora_data}/${tablespace_name}.dbf'
 size $tablespace_size
 extent management local
 uniform size 128k
 segment space management auto;
 EXIT ;
 EOF)
 echo -e "\e[1;32m  ${wind_var} \e[0m"  #Direct display returns results
 rm -rf ${outfiletmp03}
 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

本文永久更新链接地址:

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号