================================================================================
Suppose that you have Oracle & Unix
1. Connect to your database as SYSTEM and run the next script:
gen_rm_db.sql - for Oracle 7 or Oracle 8 or
gen_rm_db8.sql - for Oracle 8i.
Each of them generates Unix script (rm_db.sh or rm_db8.sh) to remove all data files,
temp data file (for Oracle 8i), log files and control files of your database.
2. Shutdown the database.
3. Run previously generated script (rm_db.sh or rm_db8.sh : 아래에 있음)
Note: Don"t forget to add execute permissions for this script before.
$ chmod 700 rm_db.sh
$ rm_db.sh
4. Remove parameter file.
======= 따라하는데 필요한 스크립트 =========
## rm_db.sh ##
REM gen_rm_db.sql
REM--------------------------------------------
REM Author: Alexander Geldutes, Nov 2000
REM W-page: http://www.geocities.com/ageldutes
REM E-mail: ageldutes@yahoo.com
REM--------------------------------------------
REM Attention! This script DOES NOT work on
REM Oracle 8i.
REM
REM Generates Unix script for removing
REM current database from disk.
REM--------------------------------------------
SET PAGES 999 LINESIZE 100 TRIMS ON ECHO OFF VERIFY OFF FEEDBACK OFF
SET SERVEROUTPUT ON
TTITLE OFF
CLEAR COLUMN
SPOOL rm_db.sh
PROMPT
declare
/* Data and log files */
cursor cdf is
select file_name
from dba_data_files
union
select member
from v$logfile;
wcount number := 1;
wplace number := 0;
wplace_old number := 0;
wcf varchar2 (255);
begin
dbms_output.enable(100000);
for rdf in cdf loop
dbms_output.put_line( "rm " || rdf.file_name );
end loop;
-- Control files
select value into wcf
from v$parameter
where name = "control_files";
while true loop
wplace_old := wplace;
wplace := InStr( wcf, ",", 1, wcount );
if wplace = 0 then
dbms_output.put_line( "rm " || SubStr(wcf, wplace_old + 1) );
exit;
end if;
dbms_output.put_line( "rm " || SubStr(wcf, wplace_old+1, wplace-wplace_old-1) );
wcount := wcount + 1;
end loop;
end;
/
SPOOL OFF
CLEAR COLUMN
SET SERVEROUTPUT OFF
SET PAGES 24 LINESIZE 80 TRIMS ON ECHO OFF VERIFY ON FEEDBACK ON
PROMPT
PROMPT Output saved at rm_db.sh
PROMPT
## gen_rm_db8.sql ##
REM gen_rm_db8.sql
REM--------------------------------------------
REM Author: Alexander Geldutes, Nov 2000
REM W-page: http://www.geocities.com/ageldutes
REM E-mail: ageldutes@yahoo.com
REM--------------------------------------------
REM Attention! This script is for Oracle 8i
REM
REM Generates Unix script for removing
REM current database from disk.
REM--------------------------------------------
SET PAGES 999 LINESIZE 100 TRIMS ON ECHO OFF VERIFY OFF FEEDBACK OFF
SET SERVEROUTPUT ON
TTITLE OFF
CLEAR COLUMN
SPOOL rm_db8.sh
PROMPT
declare
/* Data and log files */
cursor cdf is
select file_name
from dba_data_files
union
select file_name
from dba_temp_files
union
select member
from v$logfile;
wcount number := 1;
wplace number := 0;
wplace_old number := 0;
wcf varchar2 (255);
begin
dbms_output.enable(100000);
for rdf in cdf loop
dbms_output.put_line( "rm " || rdf.file_name );
end loop;
-- Control files
select value into wcf
from v$parameter
where name = "control_files";
while true loop
wplace_old := wplace;
wplace := InStr( wcf, ",", 1, wcount );
if wplace = 0 then
dbms_output.put_line( "rm " || SubStr(wcf, wplace_old + 1) );
exit;
end if;
dbms_output.put_line( "rm " || SubStr(wcf, wplace_old+1, wplace-wplace_old-1) );
wcount := wcount + 1;
end loop;
end;
/
SPOOL OFF
CLEAR COLUMN
SET SERVEROUTPUT OFF
SET PAGES 24 LINESIZE 80 TRIMS ON ECHO OFF VERIFY ON FEEDBACK ON
PROMPT
PROMPT Output saved at rm_db8.sh
PROMPT
work/oracle