Automating Database Deletion without the DBCA

In Oracle 10g, an automated database deletion script looks like this:

shutdown immediate;
startup restrict mount;
drop database;

To run the script, start SQL Plus, connect as sysdba, and run the three commands. On Windows, you'll need to use ORADIM to delete the database service afterward as well.

oradim.exe -delete -sid ORCL

Things are more involved in 9i because there's no drop command for the database. Because of this, you'll need to query the database to find all data, temp, and control files, plus all redo logs. A SQL script to generate a file deletion script is:

 set echo off feedback off head off pagesize 0 linesize 200 trimspool on spool rm_db_files.sh select 'rm '||name from v$controlfile ...

Get Oracle® DBA Automation Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.