How to write shell scripts to operate oracle delete tablespaces, create tablespaces, and delete users
This article introduces "how to write shell script operation oracle delete table space, create table space, delete user" related knowledge, in the actual case operation process, many people will encounter such a dilemma, then let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Export of table space under oracle, deletion of user, deletion of table space, user creation, table space creation, shell of data import
Execute the script using a non-oracle user
parameter name
$1: User name of base tablespace
$2: User name for synchronization tablespaces
usage scenarios
For testing, the base table space is used to upgrade and build some hardened data. Synchronous tablespaces are used for testing, flattening data each time you go to and base tablespaces
The code is as follows:
#!/ bin/sh
oraclehome=$ORACLE_HOME
echo $oraclehome
localdir="/oracle/data"
echo $localdir
#Delete existing temporary dmp files
rm -rf $localdir/$2temp.dmp
rmresult=$?
echo "rm $2temp.dmp result:$rmresult"
#Export User $1 Tablespace
su - oracle -c "exp dba/dba file=$localdir/$2temp.dmp owner=$1"
expresult=$?
if [ "$expresult" != "0" ];then
echo "exp $1 tablespace failure!!! "
fi
#Delete User $2 and its Tablespace before creating a new one
su - oracle -c "${ORACLE_HOME}/bin/sqlplus /nolog"