Oracle 新建用户shell脚本实例

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

Oracle 新建用户shell脚本实例代码: #!/bin/bash#ocpyang@126.com#create user if [ $# -ne 4 ]; then echo -e \e[1;32m ***

oracle 新建用户shell脚本实例代码:

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


if [ $# -ne 4 ]; then
  echo -e "\e[1;32m  ********************************************************************************* \e[0m"
  echo -e "\e[1;32m  Usage: $0 USERNAME PASSWORD DEFAULT_TABLESPACE INDEX_TABLESPACE \e[0m"
  echo -e "\e[1;32m  ********************************************************************************* \e[0m"
  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/

 

Linux加PHP加MySQL案例教程
Linux加PHP加MySQL案例教程

通过大量实例系统全面地介绍了Linux+PHP+MySQL环境下的网络后台开发技术,详尽分析了近30个典型案例。 本书以培养高级网站建设与管理人才为目标,内容循序渐进,由浅入深,通过大量的实例系统全面地介绍了Linux+PHP+MySQL环境下的网络后台开发技术。 本书详尽分析了近30个典型案例。包括计数器、网站流量统计、留言扳、论坛系统、聊天室、投票与调查、用户管理、新闻发布系统、广告轮播

Linux加PHP加MySQL案例教程 467
查看详情 Linux加PHP加MySQL案例教程


ora_user="sys"


ora_pass="password"

 


outfiletmp01=/tmp/createusertmp01.txt  #specify the output file location


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


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


cre_user=$1
chk_user=$(echo $1 | tr '[a-z]' '[A-Z]')
cre_user_pwd=$2
def_tbsp=$3
def_idx_tbsp=$4
def_temp_tbsp=temp
smk_test_table=t1

 


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 username from dba_users where username='${chk_user}';
spool off
exit;
!01


##check oracle instance is down or up


ins_jug=`grep -i "ORA-01034:"  ${outfiletmp01} >${outfiletmp03} `
if [  -s ${outfiletmp03} ]; 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"
 exit 0
fi

 

 

 

 


tps_jug=`grep -i ${chk_user} ${outfiletmp01} `

 

 


if [ "${tps_jug}" = "${chk_user}" ]; then
 echo -e "\e[1;31m  sorry, The username ${cre_user} exits!  \e[0m"
 exit 0


else
 wind_crtusr=$(
 sqlplus -S "${ora_user}/${ora_pass} as sysdba" /dev/null #禁止sqlplus执行结果回显
 spool ${outfiletmp02}
 CREATE USER ${cre_user} IDENTIFIED BY ${cre_user_pwd}
 DEFAULT TABLESPACE ${def_tbsp}
 TEMPORARY TABLESPACE ${def_temp_tbsp};


 GRANT CREATE SESSION TO ${cre_user};
 GRANT CREATE TABLE  TO ${cre_user};
 GRANT CREATE INDEX  TO ${cre_user};


 ALTER USER ${cre_user} QUOTA UNLIMITED ON ${def_tbsp};
 ALTER USER ${cre_user} QUOTA UNLIMITED ON ${def_idx_tbsp};


 -- Smoke test
 CONN ${cre_user}/${cre_user_pwd}
 CREATE TABLE ${smk_test_table}(tid NUMBER) TABLESPACE ${def_tbsp};
 CREATE INDEX ${smk_test_table}.idx1 ON ${cre_user}.${smk_test_table}(tid) TABLESPACE ${def_idx_tbsp};
 INSERT INTO ${smk_test_table} VALUES(1);
 DROP TABLE ${smk_ttbl};
 spool off
 exit;
 !01)
 


 # execute the variable $wind_crtusr
 if [  "${wind_crtusr}" = ""  ];then
  echo -e "\e[1;32m  ok, The create user ${cre_user} success!  \e[0m"
 else
  echo -e "\e[1;31m  ${wind_crtusr}  \e[0m"
 fi
 
 rm -rf ${outfiletmp01}
 rm -rf ${outfiletmp02}
 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号