Backup
rem
rem Filename: backup
rem Purpose: Generate script to do a simple on
rem Notes: Adjust the copy_cmnd and copy_dest variables and run from
rem sqlplus
rem Author: Frank Naude
rem
set serveroutput on
set trimspool on
set line
set head off
set feed off
spool backup
declare
copy_cmnd constant varchar
copy_dest constant varchar
dbname varchar
logmode varchar
begin
select name
into dbname
from sys
if logmode <>
raise_application_error(
return;
end if;
dbms_output
to_char(sysdate
for c
from sys
loop
dbms_output
for c
from sys
where tablespace_name = c
loop
dbms_output
end loop;
dbms_output
end loop;
dbms_output
dbms_output
copy_dest||
to_char(sysdate
dbms_output
dbms_output
end;
/
spool off
set head on
set feed on
set serveroutput off
End Backup
rem
rem Filename: end_backup
rem Purpose: Take database data files out of backup mode
rem Notes: Run from SVRMGRL
rem Author: Frank Naude
rem
connect internal
spool end_backup
select
from v$datafile f
where b
and b
/
spool off
! grep
@end_backup
! rm end_baclup
! rm end_backup
exit
或者使用這個sql
rem
rem Filename: end_backup
rem Purpose: This script will create a file called end_backup_script
rem and run it to take all tablespaces out of backup mode
rem Author: Frank Naude
rem
column cmd format a
set feedback off
set heading off
set pagesize
spool end_backup_script
select
from sys
where b
and b
group by a
/
spool off
set feedback on
set heading on
set pagesize
set termout on
start end_backup_script
#將所有錯誤記錄到一個table裡
rem
rem Filename: db
rem Purpose: Log all database errors to a table
rem Oracle
rem GRANT SELECT ON SYS
rem Date:
rem Author: Nico Booyse ()
rem
drop trigger log_errors_trig;
drop table log_errors_tab;
create table log_errors_tab (
error varchar
timestamp date
username varchar
osuser varchar
machine varchar
process varchar
program varchar
create or replace trigger log_errors_trig
after servererror on database
declare
var_user varchar
var_osuser varchar
var_machine varchar
var_process varchar
var_program varchar
begin
select username
into var_user
from sys
where audsid = userenv(
insert into log_errors_tab
values(dbms_standard
var_osuser
end;
/
From:http://tw.wingwit.com/Article/program/Oracle/201311/17669.html