我使用這個,它工作得很好。
- 1.創建計劃:
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name=>'user.TABLESPACE_MANAGEMENT',
program_action=>'begin
EXECUTE IMMEDIATE
'CREATE TABLE IDLE_TIME_TABLE
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING
AS
SELECT DISTINCT
SID,
OSUSER,
USERNAME,
STATUS,
TO_CHAR(LOGON_TIME, ''DDth DAY HH24:MI:SS'') LOGON_TIME,
FLOOR(LAST_CALL_ET/3600)||'':''|| FLOOR(MOD(LAST_CALL_ET,3600)/60)||'':''||MOD(MOD(LAST_CALL_ET,3600),60) IDLE,
PROGRAM
FROM V$SESSION
WHERE USERNAME IS NOT NULL
AND STATUS = ''INACTIVE''
ORDER BY IDLE DESC',
program_type=>'PLSQL_BLOCK',
number_of_arguments=>0,
comments=>'TABLESPACE MANAGEMENT CREATES A TABLE CALLED TABLESPACE_MANAGEMNT ON DAILY BASIS',
enabled=>TRUE);
END;
- 2.創建一個日程安排程序:
BEGIN
sys.dbms_scheduler.create_schedule(
repeat_interval =>
'FREQ=DAILY; BYDAY=MON,TUE,WED,THU,FRI; BYHOUR=22; BYMINUTE=0; BYSECOND=0;',
start_date =>
to_timestamp_tz('2011-07-26 US/Eastern', 'YYYY-MM-DD TZR'),
comments =>
'Schedule for what ever u want',
schedule_name => '"user"."TABLESPACE_MANAGEMENT_SCHEDULE"');
END;
--3。最後同時連結在一起,創建一個作業:
BEGIN
sys.dbms_scheduler.create_job(
job_name => '"user"."SPACE"',
program_name => 'user.TABLESPACE_MANAGEMENT',
schedule_name => 'user.TABLESPACE_MANAGEMENT_SCHEDULE',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'TABLESPCE_MANAGEMENT',
auto_drop => FALSE,
enabled => TRUE);
END;
現在你可以使用類似utl_mail.send
begin
UTL_MAIL.SEND_ATTACH_VARCHAR2
(
sender => '[email protected]'
,recipients => '[email protected],[email protected],[email protected],[email protected]'
,cc => NULL
,bcc => NULL
,subject => 'send_attach_varchar2'
,message => 'here is a test of send_attach_varchar2'
,mime_type => 'text/plain; charset=us-ascii'
,priority => 3
,attachment => '<html>
<head>
<title>Test HTML message</title>
</head>
<body>
<p>This is a <b>HTML</b> <i>version</i> of the test message.</p>
<p><img src="http://whatever/images/site_logo.gif" alt="Site Logo" />
</body>
</html>'
,att_inline => TRUE
,att_mime_type=>'application/html'
,att_filename => 'cartesien.html'
);
你想怎麼通知?電子郵件?短信?消息框在屏幕上? – APC 2009-12-02 10:56:15
http://no0p.github.io/postgresql/2014/10/21/postgresql-monitoring-framework.html plus http://oss.oetiker.ch/rrdtool/gallery/index.en.html – 2016-02-08 10:56:24
畢竟這些年,如果我可以問,你是如何最終解決它的? – kmonsoor 2018-01-24 16:35:09