婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

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

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

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

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 '/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命令導出表空間數(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)建用戶、導入dmp文件
  • Oracle 刪除用戶和表空間詳細介紹
  • Linux下Oracle刪除用戶和表空間的方法
  • Oracle新建用戶、角色,授權(quán),建表空間的sql語句
  • Oracle數(shù)據(jù)庫的實例/表空間/用戶/表之間關系簡單講解

標簽:婁底 馬鞍山 許昌 邵陽 赤峰 巴彥淖爾 淘寶邀評 金昌

巨人網(wǎng)絡通訊聲明:本文標題《shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶》,本文關鍵詞  shell,腳本,操作,oracle,刪除,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關。
  • 相關文章
  • 下面列出與本文章《shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶》相關的同類信息!
  • 本頁收集關于shell腳本操作oracle刪除表空間、創(chuàng)建表空間、刪除用戶的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 台南县| 横峰县| 石屏县| 敦化市| 三亚市| 夏津县| 奉新县| 克山县| 仙桃市| 垦利县| 瑞安市| 临安市| 定西市| 阜城县| 平泉县| 长治县| 和田市| 浪卡子县| 武城县| 高青县| 新源县| 梁河县| 土默特左旗| 宜章县| 花莲市| 门头沟区| 平顶山市| 娱乐| 略阳县| 安多县| 衡水市| 安康市| 岚皋县| 新宁县| 伊春市| 瓮安县| 双鸭山市| 江油市| 七台河市| 彭阳县| 无锡市|