Practice: oracle deletes shell scripts for tablespace, oracleshell

Source: Internet
Author: User

Practice: oracle deletes shell scripts for tablespace, oracleshell

#! /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

 

 

 

 


How to completely delete users and tablespaces created by oracle

If you want to delete a tablespace, you can delete the corresponding file. In this way, you can drop tablespace ocscdrbak including contents; drop tablespace tablespace_name including contents and datafiles;
Windows requires offline.

How can I create a tablespace after deleting a tablespace with data in oracle at 10 Gb?

Drop tablespace tbsname include contents and datafiles;
And then try again.
Create tablespace tbsname datafile 'file path and file name' size 500 m;

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.