Home
php教程
PHP开发
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
oracle下表空间的导出,用户的删除,表空间删除,用户新建,表空间新建,数据导入的shell
使用非oracle用户执行该脚本
参数说名
$1:base表空间的用户名
$2:同步表空间的用户名
使用场景
测试用,base表空间用于升级建立一些固化数据。同步表空间用于测试用,每次去和base表空间拉平数据
#!/bin/sh oraclehome=$ORACLE_HOME echo $oraclehome localdir="/oracle/data" echo $localdir #删除已经存在的临时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命令导出表空间数据到用户$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
Copy after login
更多shell脚本操作oracle删除表空间、创建表空间、删除用户相关文章请关注PHP中文网!
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

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
3 weeks ago
By DDD
Roblox: Dead Rails - How To Complete Every Challenge
4 weeks ago
By DDD
Atomfall guide: item locations, quest guides, and tips
4 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1393
52


nyt mini crossword answers
37
110

