WEB工程数据库相关安装脚本写作
1. 数据库oracle安装
2. 数据库用户创建,表空间创建,表创建
#!/bin/bash current_path=`pwd`
create_tablespace=${current_path}/create_tablespace.sql
create_tables=${current_path}/create_tables.sql
install_log=${current_path}/installlog.log
sqllog=${current_path}/sql.log function create_table_space
{
if [ ! -f ${create_tablespace} ]; then
echo "${create_tablespace} is not exist "
return 1
fi
logger "info" "executing ${create_tablespace}..." sqlplus / as sysdba >${sqllog}<<EOF
@${create_tablespace}
EOF
if [ $? != 0 ]; then
logger "error" "create table space failed"
return 1
fi error_info=`grep "ERROR" ${sqllog}`
if [ "${error_info}X" != "X" ]; then
logger "error" "create table space failed"
cat ${sqllog}
return 1
fi
logger "info" "create table space success"
return 0
} function create_tables
{
if [ ! -f ${create_tables} ]; then
logger "error" "${create_tables} is not exist.."
return 1
fi
logger "info" "executing create tables..."
sqlplus rocky/rocky12345@ora11g >>${sqllog}<<EOF
@${create_tables}
EOF
if [ $? != 0 ]; then
logger "error" "create tables failed..."
return 1
fi error_info=`grep ERROR ${sqllog}`
if [ "${error_info}X" != "X" ]; then
logger "error" "create tables failed..."
return 1
fi
logger "info" "create tables success..."
return 0
} function main
{
echo "start install rocky" >${install_log}
echo `date`>>${install_log}
echo "start install rocky"
echo "[step 1] create table space"
create_table_space
if [ $? != 0 ]; then
return 1
fi echo "[step 2] create tables"
create_tables if [ $? != 0 ]; then
return 1
fi } function logger
{
if [ $# == 2 ]; then
echo "[$1]:[$2]"
echo "[$1]:[$2]" >>${install_log}
return
fi
} main $*
主安装脚本
create or replace procedure clean_user
as
v_count integer;
begin
select count(*) into v_count from user_tablespaces where upper(tablespace_name)=upper('rocky_default');
If v_count > 0 Then
Execute immediate 'drop tablespace rocky_default including contents and datafiles cascade constraints';
end if; Execute immediate 'create tablespace rocky_default datafile ''/home/oracle/test/rocky.dbf'' size 100M autoextend on next 10M maxsize 500M';
Execute immediate 'create user rocky identified by rocky12345 default tablespace rocky_default';
Execute immediate 'GRANT CONNECT,RESOURCE,CREATE ANY TABLE,DROP ANY TABLE,CREATE SEQUENCE,DROP ANY SEQUENCE, CREATE DATABASE LINK, CREATE VIEW to rocky'; end;
/
execute clean_user;
/
exit;
create_tablespace.sql
create or replace procedure clean_tables
as
v_count integer;
begin
select count(*) into v_count from user_tables where upper(table_name)=upper('T_MEMBER_INFO');
If v_count > 0 Then
Execute immediate 'drop table T_MEMBER_INFO';
end if;
end;
/
execute clean_tables;
/ create table T_MEMBER_INFO
(
username varchar(200) not null,
password varchar(100) not null,
groupid number(9) not null
);
alter table T_MEMBER_INFO add constraint PK_MEMBER_USERNAME primary key (username);
exit;
/
create_tables.sql
WEB工程数据库相关安装脚本写作的更多相关文章
- 【转载】linux-查询rpm包相关安装、卸载脚本
测试过程中,有时要测试开发自己打的rpm包,为了确认打包正确,需要查询rpm包相关安装.卸载脚本,可以使用命令: [root@6 /]#rpm -q --scripts mysql pos ...
- Nginx+Python+uwsgi+Django的web开发环境安装及配置
Nginx+Python+uwsgi+Django的web开发环境安装及配置 nginx安装 nginx的安装这里就略过了... python安装 通常系统已经自带了,这里也略过 uwsgi安装 官网 ...
- Azkaban2.5安装部署(系统时区设置 + 安装和配置mysql + Azkaban Web Server 安装 + Azkaban Executor Server安装 + Azkaban web server插件安装 + Azkaban Executor Server 插件安装)(博主推荐)(五)
Azkaban是什么?(一) Azkaban的功能特点(二) Azkaban的架构(三) Hadoop工作流引擎之Azkaban与Oozie对比(四) 不多说,直接上干货! http://www.cn ...
- 一个比较完整的Inno Setup 安装脚本(转)
一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了. [Setup] ; 注: AppId的值为单独标识该应用程序. ; 不要为其他安装程序使用相 ...
- Linux环境下JDK/Eclipse一键安装脚本
-------------------------------------------------------------------- author:jiangxin Email:jiangxinn ...
- 一个比较完整的Inno Setup 安装脚本
一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了. [Setup] ; 注: AppId的值为单独标识该应用程序. ; 不要为其他安装程序使用相 ...
- LAMP最新源码一键安装脚本
Linux+Apache+MySQL+PHP (脚本可以选择是否安装+Pureftpd+User manager for PureFTPd+phpMyAdmin+memcache),添加虚拟主机请执行 ...
- centos5.5 Apache2 Web 服务器的安装
# vi /etc/httpd/conf/httpd.conf 把以下虚拟机的配置加在 httpd.conf 文件末尾即可 NameVirtualHost *:80 // ...
- fabric镜像安装脚本分析
#!/bin/bash # # Copyright IBM Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0 # e ...
随机推荐
- 看个人思路吧,清晰的话就简单 CodeForces 271A - Beautiful Year
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is ...
- jQuery支持mobile的全屏水平横向翻页效果
这是一款支持移动手机mobile设备的jQuery全屏水平横向翻页效果插件. 该翻页插件能够使页面在水平方向上左右全屏翻动,它支持手机触摸屏,支持使用鼠标滚动页面. 整个页面过渡平滑,效果很不错. 在 ...
- 基于XMPP实现的Openfire的配置安装+Android客户端的实现[转]
最近在整理一些这方面的资料,闲话少说,咱还是直奔主题吧 :) http://blog.csdn.net/sk719887916/article/details/40541163 https://git ...
- 关于PHP定时执行任务的实现(转)
PHP在这方面应该说是比较弱,如果只用php去实现可以如下: <?php ignore_user_abort();//关闭浏览器后,继续执行php代码 set_time_limit(0);//程 ...
- Java基础知识强化之集合框架笔记23:ArrayList的实现原理
1. ArrayList的实现原理: 这个可以直接参考网友的博客:http://www.cnblogs.com/ITtangtang/p/3948555.html
- 关于css中伪类及伪元素的总结
css中的伪类和伪元素总是混淆,今天参考了很多资料,也查看了部分文档,现将伪类及伪元素总结如下: 一.由来: 伪类和伪元素的引入都是因为在文档树里有些信息无法被充分描述,比如CSS没有"段落 ...
- 10.18 noip模拟试题
分火腿 (hdogs.pas/.c/.cpp) 时间限制:1s:内存限制 64MB 题目描述: 小月言要过四岁生日了,她的妈妈为她准备了n根火腿,她想将这些火腿均分给m位小朋友,所以她可能需要切火腿. ...
- css3 calc()
概述 CSS函数calc()可以用在任何一个需要<length>的地方.有了calc(),你可以通过计算来决定一个对象的大小和形状. 你还可以在一个calc()内部嵌套另一个calc(). ...
- HTML5媒体播放说明
HTML5中video标签播放m3u8整理 http://www.xue163.com/588880/39097/390970871.html 移动端HTML5<video>视频播放优化实 ...
- Sql server 数据库中,纯SQL语句查询、执行 单引号问题。
在默认值情况下, select 'abc',Titile from tb_Name; ---输出内容 是abc: 如果想输出 单引号 'abc,需要使用select '''abc',Titile f ...