亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home php教程 PHP開發(fā) Shell script operates oracle to delete table space, create table space and delete user

Shell script operates oracle to delete table space, create table space and delete user

Jan 06, 2017 am 10:45 AM

oracle下表空間的導出,用戶的刪除,表空間刪除,用戶新建,表空間新建,數(shù)據(jù)導入的shell
使用非oracle用戶執(zhí)行該腳本
參數(shù)說名
$1:base表空間的用戶名
$2:同步表空間的用戶名
使用場景
測試用,base表空間用于升級建立一些固化數(shù)據(jù)。同步表空間用于測試用,每次去和base表空間拉平數(shù)據(jù)

#!/bin/sh
oraclehome=$ORACLE_HOME
echo $oraclehome
localdir="/oracle/data"
echo $localdir
#刪除已經(jīng)存在的臨時dmp文件
rm -rf $localdir/$2temp.dmp
rmresult=$?
echo "rm $2temp.dmp result:$rmresult"
#將用戶$1的表空間導出
su - oracle -c "exp dba/dba file=$localdir/$2temp.dmp owner=$1"
expresult=$?
if [ "$expresult" != "0" ];then
        echo "exp $1 tablespace failure!!!"
fi
#先刪除用戶$2及其表空間,然后再新建該用戶及表空間
su - oracle -c "${ORACLE_HOME}/bin/sqlplus /nolog" <<EOF
connect / as sysdba
drop user $2 cascade;
drop tablespace $2 including contents and datafiles;
create tablespace $2 datafile &#39;/oracle/product/10.2.0/oradata/$2.dbf&#39; size 5M autoextend on;
create user $2 identified by "$2" default tablespace $2 temporary tablespace TEMP profile DEFAULT;
grant connect to $2;
grant resource to $2;
grant create any table to $2;
grant create any trigger to $2;
grant create any type to $2;
grant create any view to $2;
grant unlimited tablespace to $2;
exit
EOF
crdrresult=$?
if [ "$crdrresult" != "0" ];then
        echo "drop user and tablespace failure!!!"
        echo "create user and tablespace failure!!!"
else
#剛建完的用戶不能馬上使用,等候10秒
        sleep 10s
#更換dmp文件中的表空間名
        sed -i &#39;s/TABLESPACE "$1"/TABLESPACE "$2"/g&#39; $localdir/$2temp.dmp
#使用imp命令導出表空間數(shù)據(jù)到用戶$2的表空間
        su - oracle -c "imp dba/dba file=$localdir/$2temp.dmp  fromuser=$1 touser=$2"
        impresult=$?
        if [ "$impresult" != "0" ];then
                echo "imp failure!!!"
        else
                echo "imp success!!!"
        fi
fi

更多shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶相關(guān)文章請關(guān)注PHP中文網(wǎng)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72