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工程数据库相关安装脚本写作的更多相关文章

  1. 【转载】linux-查询rpm包相关安装、卸载脚本

        测试过程中,有时要测试开发自己打的rpm包,为了确认打包正确,需要查询rpm包相关安装.卸载脚本,可以使用命令:   [root@6 /]#rpm -q --scripts mysql pos ...

  2. Nginx+Python+uwsgi+Django的web开发环境安装及配置

    Nginx+Python+uwsgi+Django的web开发环境安装及配置 nginx安装 nginx的安装这里就略过了... python安装 通常系统已经自带了,这里也略过 uwsgi安装 官网 ...

  3. Azkaban2.5安装部署(系统时区设置 + 安装和配置mysql + Azkaban Web Server 安装 + Azkaban Executor Server安装 + Azkaban web server插件安装 + Azkaban Executor Server 插件安装)(博主推荐)(五)

    Azkaban是什么?(一) Azkaban的功能特点(二) Azkaban的架构(三) Hadoop工作流引擎之Azkaban与Oozie对比(四) 不多说,直接上干货! http://www.cn ...

  4. 一个比较完整的Inno Setup 安装脚本(转)

    一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了. [Setup] ; 注: AppId的值为单独标识该应用程序. ; 不要为其他安装程序使用相 ...

  5. Linux环境下JDK/Eclipse一键安装脚本

    -------------------------------------------------------------------- author:jiangxin Email:jiangxinn ...

  6. 一个比较完整的Inno Setup 安装脚本

    一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了. [Setup] ; 注: AppId的值为单独标识该应用程序. ; 不要为其他安装程序使用相 ...

  7. LAMP最新源码一键安装脚本

    Linux+Apache+MySQL+PHP (脚本可以选择是否安装+Pureftpd+User manager for PureFTPd+phpMyAdmin+memcache),添加虚拟主机请执行 ...

  8. centos5.5 Apache2 Web 服务器的安装

    # vi /etc/httpd/conf/httpd.conf 把以下虚拟机的配置加在 httpd.conf  文件末尾即可 NameVirtualHost *:80               // ...

  9. fabric镜像安装脚本分析

    #!/bin/bash # # Copyright IBM Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0 # e ...

随机推荐

  1. DB2 数据库绑定用户授权命令

    1.1  数据库绑定用户授权命令 db2 connect to opca db2 grant dbadm,createtab,bindadd,connect,create_not_fenced_rou ...

  2. LeetCode——Linked List Cycle

    Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...

  3. ★ Linked List Cycle II -- LeetCode

    证明单链表有环路: 本文所用的算法 能够 形象的比喻就是在操场其中跑步.速度快的会把速度慢的扣圈  能够证明,p2追赶上p1的时候.p1一定还没有走完一遍环路,p2也不会跨越p1多圈才追上  我们能够 ...

  4. Apple-Watch开发1

    Communicating between the iOS app and the Watch Extension There are four scenarios where an app and ...

  5. 汉诺塔-Hanoi

    1. 问题来源: 汉诺塔(河内塔)问题是印度的一个古老的传说. 法国数学家爱德华·卢卡斯曾编写过一个印度的古老传说:在世界中心贝拿勒斯(在印度北部)的圣庙里,一块黄铜板上插着三根宝石针.印度教的主神梵 ...

  6. rabbitmq 消息持久化之receive and send

    二: 任务分发 &消息持久化   启用多个接收端的时候如果某一个receive 关闭要保证消息有反馈是否收到   send端 #-*- coding: UTF-8 -*-import pika ...

  7. Maven Integration for Eclipse 正确地址

    m2eclipse has moved from sonatype to eclipse. The correct update site is http://download.eclipse.org ...

  8. JavaScript 使用

    HTML 中的脚本必须位于 <script> 与 </script> 标签之间. 脚本可被放置在 HTML 页面的 <body> 和 <head> 部分 ...

  9. PL/SQL Select into 异常处理

    在使用select into 为变量赋值时,如果变量是集合类型,不会产生异常,而如果是基本类型或记录类型,则会报异常. 异常产生了怎么办?当然是捕获并处理啦. 对于普通的代码块来说,在代码块的结尾处理 ...

  10. win7、xp下Meclipse SVN用户名修改

    Meclipse SVN用户名修改,在网上查找后发现如下方法: 1.查看你的Eclipse中使用的是什么SVNInterface windows>preference>Team>SV ...