Oracle

在 shell 腳本的 sql 語句中無法辨識 v$ 表

  • April 6, 2020

我有這個塊的 .sh 腳本:

sqlplus -S / as sysdba <<EOFILE

set feedback off
set lines 2000
set pages 20000
col db_size for a15
alter session set nls_date_format = 'DD-MM-YYYY HH24:MI:SS';

select * from ( select "START_TIME", "END_TIME", INPUT_BYTES_DISPLAY db_size from v$RMAN_BACKUP_JOB_DETAILS order by "END_TIME" DESC) where ROWNUM <= 5;

EOFILE

EOF

但輸出是這個錯誤:

select * from ( select “START_TIME”, “END_TIME”, INPUT_BYTES_DISPLAY db_size from v order by “END_TIME” DESC) where ROWNUM <= 5 * ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed這裡

我知道訪問 v$RMAN_BACKUP_JOB_DETAILS 存在問題,但我應該如何解決這個問題?

我試過:

v\$RMAN_BACKUP_JOB_DETAILS
'v$RMAN_BACKUP_JOB_DETAILS'
"v$RMAN_BACKUP_JOB_DETAILS"

有人能幫我嗎?謝謝

嘗試:sqlplus -S / as sysdba &lt;&lt;'EOFILE' ...

加上引號告訴 shell 不要解釋 here 文件的內容:它不會嘗試將 here 文件中的 $XXX 解釋為 shell 變數。

引用自:https://dba.stackexchange.com/questions/264406