Oracle deletes a shell script instance for a tablespace

Source: Internet
Author: User

Oracle deletes a shell script instance for a tablespace

Shell script code for Oracle tablespace Deletion

#! /Bin/bash
# Ocpyang@126.com
# Drop tablespace

If [$ #-ne 1]; then
Echo "Usage: $0 TABLESPACE_NAME"
Exit 1
Fi

# Configure oracle env: about oracle envs, username and password

ORACLE_SID = orcl

ORACLE_HOME =/u01/app/oracle/product/11.2.0/db_1

Ora_data =/u01/app/oracle/product/11.2.0/db_1/dbs/


Ora_user = "sys" # oracle username

Ora_pass = "password" # oracle user password

Tablespace_name = $ (echo $1 | tr '[a-z] ''[A-Z]')

Outfiletmp =/tmp/droptpstmp01.txt # specify the output file location

 


Sqlplus-S "$ {ora_user}/$ {ora_pass} as sysdba" <! 01>/dev/null # disable display of sqlplus execution results
Set heading off;
Set feedback off;
Set termout off;
Set pagesize 0;
Set verify off;
Set echo off;
Spool $ {outfiletmp}
Select tablespace_name from dba_tablespaces where tablespace_name = '$ {tablespace_name }';
Spool off
Exit;
! 01

 

Tps_jug = 'grep-I $ {tablespace_name }$ {outfiletmp }'

 

If ["$ {tps_jug}" = "$ {tablespace_name}"]; then
Wind_var = $ (
Sqlplus-s "{ora_user}/$ {ora_pass} as sysdba" <EOF
Set heading off
Drop tablespace $ {tablespace_name} including contents and datafiles;
EXIT;
EOF)
Echo-e "\ e [1; 32 m $ {wind_var} \ e [0 m" # Direct display returns results
Rm-rf $ {outfiletmp}
Exit 1
Else
Echo-e "\ e [1; 31 m ------------------------------------------- \ e [0 m"
Echo-e "\ e [1; 31 m The tablespace $ {tablespace_name} not exits! \ E [0 m"
Echo-e "\ e [1; 31 m ------------------------------------------- \ e [0 m"
Rm-rf $ {outfiletmp}
Exit 1

Fi

Oracle 11g installation manual on RedHat Linux 5.8 _ x64 Platform

Installing Oracle 12C in Linux-6-64

Install Oracle 11gR2 (x64) in CentOS 6.4)

Steps for installing Oracle 11gR2 in vmwarevm

Install Oracle 11g XE R2 In Debian

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.