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;