濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶

shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶

熱門標(biāo)簽:華鋒e路航港口地圖標(biāo)注 客服外呼系統(tǒng)怎么樣 打電話機(jī)器人接我是他的秘書 江蘇云電銷機(jī)器人公司 地圖標(biāo)注員都是年輕人 揭陽智能電話機(jī)器人推薦 河南信譽(yù)好的不封卡電話外呼系統(tǒng) 百度地圖標(biāo)注錯(cuò)了有責(zé)任嗎 如果做線上地圖標(biāo)注

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

復(fù)制代碼 代碼如下:

#!/bin/sh
oraclehome=$ORACLE_HOME
echo $oraclehome
localdir="/oracle/data"
echo $localdir
#刪除已經(jīng)存在的臨時(shí)dmp文件
rm -rf $localdir/$2temp.dmp
rmresult=$?
echo "rm $2temp.dmp result:$rmresult"
#將用戶$1的表空間導(dǎo)出
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 '/oracle/product/10.2.0/oradata/$2.dbf' 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 's/TABLESPACE "$1"/TABLESPACE "$2"/g' $localdir/$2temp.dmp
#使用imp命令導(dǎo)出表空間數(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

您可能感興趣的文章:
  • 使用sqlplus命令行工具為oracle創(chuàng)建用戶和表空間
  • oracle創(chuàng)建表空間、授權(quán)、創(chuàng)建用戶、導(dǎo)入dmp文件
  • Oracle 刪除用戶和表空間詳細(xì)介紹
  • Linux下Oracle刪除用戶和表空間的方法
  • Oracle新建用戶、角色,授權(quán),建表空間的sql語句
  • Oracle數(shù)據(jù)庫(kù)的實(shí)例/表空間/用戶/表之間關(guān)系簡(jiǎn)單講解

標(biāo)簽:婁底 馬鞍山 許昌 邵陽 赤峰 巴彥淖爾 淘寶邀評(píng) 金昌

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶》,本文關(guān)鍵詞  shell,腳本,操作,oracle,刪除,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    南汇区| 高州市| 通山县| 大港区| 务川| 饶阳县| 永年县| 都江堰市| 成都市| 曲阳县| 昆明市| 沁源县| 宝兴县| 衡阳市| 新营市| 当涂县| 团风县| 南溪县| 宣威市| 莎车县| 木里| 苗栗县| 呼图壁县| 兴城市| 凤城市| 遂川县| 澄迈县| 梁山县| 岢岚县| 怀柔区| 栾城县| 勐海县| 将乐县| 珲春市| 大埔区| 梅州市| 兴和县| 万盛区| 永善县| 泰安市| 江达县|