我想每 6 小时将 UNDO 表空间的统计信息存储在一个表中。我创建了简单的表:
CREATE TABLE SYS.TB_UNDOSTAT (
MAX_UNDOBLKS NUMBER,
MAX_QUERY_LENGTH NUMBER,
MAX_QUERY_ID VARCHAR2(13),
DATE_OF_STAT DATE,
DMY_OF_STAT VARCHAR2(30),
TIME_OF_STAT VARCHAR2(30));
之后,我创建了 Oracle 外部作业:
BEGIN
DBMS_SCHEDULER.CREATE_JOB
(job_name=>'ACCUMULATE_UNDOSTAT',
repeat_interval =>'FREQ=DAILY; BYHOUR=05,11,17,23',
job_type=>'EXECUTABLE',
job_action=>'/home/oracle/scripts/UNDOSTAT/accumulate_undostat_111.bsh',
enabled =>TRUE,
auto_drop=>FALSE,
comments=>'Take accumulate statistics from V$UNDOSTAT to
SYS.TB_UNDOSTAT one time through 6 hours On 111 Server'
);
END;
accumulate_undostat_111.bsh 文件内容为:
#!/bin/bash
export ORACLE_HOME=/u01/home/oracle/product/11.2.0/db_1
export ORACLE_SID=parustest
export PATH=$ORACLE_HOME/bin:$PATH
sqlplus -s << EOF
/ as sysdba
INSERT INTO FGA_OWNER.TB_UNDOSTAT (MAX_UNDOBLKS, MAX_QUERY_LENGTH,
MAX_QUERY_ID, DATE_OF_STAT, DMY_OF_STAT, TIME_OF_STAT)
SELECT max(undoblks), max(maxquerylen), maxqueryid, sysdate, to_char(sysdate,'DD.MM.YYYY'),
to_char(sysdate,'HH24:MI:SS') FROM SYS.V_$UNDOSTAT GROUP BY maxqueryid;
COMMIT;
exit;
EOF
exit 0
作业创建没有任何问题。已授予所有必要的权限。但是当我调试我的 shell 脚本时,我遇到了一些问题:
[oracle@parustest111 UNDOSTAT]$ bash -o xtrace accumulate_undostat_111.bsh + export ORACLE_HOME=/u01/home/oracle/product/11.2.0/db_1
+ ORACLE_HOME=/u01/home/oracle/product/11.2.0/db_1
+ export ORACLE_SID=parustest
+ ORACLE_SID=parustest
+ export PATH=/u01/home/oracle/product/11.2.0/db_1/bin:/u01/home/oracle/product/11.2.0/db_1/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
+ PATH=/u01/home/oracle/product/11.2.0/db_1/bin:/u01/home/oracle/product/11.2.0/db_1/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
+ sqlplus -s
to_char(sysdate,'HH24:MI:SS') FROM V_ GROUP BY maxqueryid
*
ERROR at line 4:
ORA-00942: table or view does not exist
Elapsed: 00:00:00.00
Commit complete.
Elapsed: 00:00:00.00
+ exit 0
[oracle@parustest111 UNDOSTAT]$
有人可以解释并帮助我吗?谢谢!