首页 技术 正文
技术 2022年11月15日
0 收藏 456 点赞 2,612 浏览 2507 个字

1. 数据库oracle安装

2. 数据库用户创建,表空间创建,表创建

#!/bin/bashcurrent_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.logfunction 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

下一篇: SPSS问题
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,958
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,482
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,328
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,111
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,743
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,777