从 Oracle 中的假脱机中删除 "connection established"
Remove "connection established" from spooling in Oracle
如何删除 SQL 脚本中的字符串“connection established”,该脚本连接到不同的数据库并在一个全局文件中假脱机一些输出?
这实际上是我的简单脚本:
set feedback off
set echo off
set lines 200
set pages 999
spool check_control_file_record_keep_time.txt;
conn /@"HOST1:1521/DB1"
set echo off
set feedback off
set serveroutput on
DECLARE
actual_param_setting NUMBER;
BEGIN
select value into actual_param_setting from v$parameter where name='control_file_record_keep_time';
IF actual_param_setting >= 11 THEN
DBMS_OUTPUT.PUT_LINE('[OK] - DB1 - Parameter control_file_record_keep_time for this database is OK!');
ELSE
DBMS_OUTPUT.PUT_LINE('[NOK] - DB1 - Parameter control_file_record_keep_time need to be changed for this database!');
END IF;
END;
/
conn /@"HOST2:1521/DB2"
set echo off
set feedback off
set serveroutput on
DECLARE
actual_param_setting NUMBER;
BEGIN
select value into actual_param_setting from v$parameter where name='control_file_record_keep_time';
IF actual_param_setting >= 11 THEN
DBMS_OUTPUT.PUT_LINE('[OK] - DB2 - Parameter control_file_record_keep_time for this database is OK!');
ELSE
DBMS_OUTPUT.PUT_LINE('[NOK] - DB2 - Parameter control_file_record_keep_time need to be changed for this database!');
END IF;
END;
/
conn /@"HOST3:1521/DB3"
set echo off
set feedback off
set serveroutput on
DECLARE
actual_param_setting NUMBER;
BEGIN
select value into actual_param_setting from v$parameter where name='control_file_record_keep_time';
IF actual_param_setting >= 11 THEN
DBMS_OUTPUT.PUT_LINE('[OK] - DB3 - Parameter control_file_record_keep_time for this database is OK!');
ELSE
DBMS_OUTPUT.PUT_LINE('[NOK] - DB3 - Parameter control_file_record_keep_time need to be changed for this database!');
END IF;
END;
/
spool off;
exit
这是假脱机文件中的输出
Connection established.
[NOK] - DB1 - Parameter control_file_record_keep_time need to be changed for this database!
Connection established.
[NOK] - DB2 - Parameter control_file_record_keep_time need to be changed for this database!
Connection established.
[NOK] - DB3 - Parameter control_file_record_keep_time need to be changed for this database!
任何“丢弃”“已建立的连接”的想法。通过在 sqlplus 中执行?
您可以在调用 SQL*Plus 时使用 -s[ilent]
标志; from the documentation:
3.5.1.10 SILENT Option
-S[ILENT]
Suppresses all SQL*Plus information and prompt messages, including the command prompt, the echoing of commands, and the banner normally displayed when you start SQL*Plus. If you omit username or password, SQL*Plus prompts for them, but the prompts are not visible! Use SILENT
to invoke SQL*Plus within another program so that the use of SQL*Plus is invisible to the user.
这也适用于在程序中发出的 connect
命令,而不仅仅是初始连接(如果有的话;您可能正在使用 /nolog
)。
然后,您还可以将输出重定向到一个文件,作为使用假脱机的替代方法 - 默认情况下,横幅等会出现在输出中,但由于这抑制了它,所以输出更清晰。
如何删除 SQL 脚本中的字符串“connection established”,该脚本连接到不同的数据库并在一个全局文件中假脱机一些输出?
这实际上是我的简单脚本:
set feedback off
set echo off
set lines 200
set pages 999
spool check_control_file_record_keep_time.txt;
conn /@"HOST1:1521/DB1"
set echo off
set feedback off
set serveroutput on
DECLARE
actual_param_setting NUMBER;
BEGIN
select value into actual_param_setting from v$parameter where name='control_file_record_keep_time';
IF actual_param_setting >= 11 THEN
DBMS_OUTPUT.PUT_LINE('[OK] - DB1 - Parameter control_file_record_keep_time for this database is OK!');
ELSE
DBMS_OUTPUT.PUT_LINE('[NOK] - DB1 - Parameter control_file_record_keep_time need to be changed for this database!');
END IF;
END;
/
conn /@"HOST2:1521/DB2"
set echo off
set feedback off
set serveroutput on
DECLARE
actual_param_setting NUMBER;
BEGIN
select value into actual_param_setting from v$parameter where name='control_file_record_keep_time';
IF actual_param_setting >= 11 THEN
DBMS_OUTPUT.PUT_LINE('[OK] - DB2 - Parameter control_file_record_keep_time for this database is OK!');
ELSE
DBMS_OUTPUT.PUT_LINE('[NOK] - DB2 - Parameter control_file_record_keep_time need to be changed for this database!');
END IF;
END;
/
conn /@"HOST3:1521/DB3"
set echo off
set feedback off
set serveroutput on
DECLARE
actual_param_setting NUMBER;
BEGIN
select value into actual_param_setting from v$parameter where name='control_file_record_keep_time';
IF actual_param_setting >= 11 THEN
DBMS_OUTPUT.PUT_LINE('[OK] - DB3 - Parameter control_file_record_keep_time for this database is OK!');
ELSE
DBMS_OUTPUT.PUT_LINE('[NOK] - DB3 - Parameter control_file_record_keep_time need to be changed for this database!');
END IF;
END;
/
spool off;
exit
这是假脱机文件中的输出
Connection established.
[NOK] - DB1 - Parameter control_file_record_keep_time need to be changed for this database!
Connection established.
[NOK] - DB2 - Parameter control_file_record_keep_time need to be changed for this database!
Connection established.
[NOK] - DB3 - Parameter control_file_record_keep_time need to be changed for this database!
任何“丢弃”“已建立的连接”的想法。通过在 sqlplus 中执行?
您可以在调用 SQL*Plus 时使用 -s[ilent]
标志; from the documentation:
3.5.1.10 SILENT Option
-S[ILENT]
Suppresses all SQL*Plus information and prompt messages, including the command prompt, the echoing of commands, and the banner normally displayed when you start SQL*Plus. If you omit username or password, SQL*Plus prompts for them, but the prompts are not visible! UseSILENT
to invoke SQL*Plus within another program so that the use of SQL*Plus is invisible to the user.
这也适用于在程序中发出的 connect
命令,而不仅仅是初始连接(如果有的话;您可能正在使用 /nolog
)。
然后,您还可以将输出重定向到一个文件,作为使用假脱机的替代方法 - 默认情况下,横幅等会出现在输出中,但由于这抑制了它,所以输出更清晰。