当您通过 sqlplus 运行 大量插入语句时仅打印错误

print just errors when you run a large number of insert statement via sqlplus

我需要加载包含数千条记录的 table。

我生成了一个 .sql 文件,如下所示:

INSERT into TABLE(OLD,NEW) VALUES('A1','B1');
INSERT into TABLE(OLD,NEW) VALUES('A2','B2');
INSERT into TABLE(OLD,NEW) VALUES('A3','B3');
(...)
INSERT into TABLE(OLD,NEW) VALUES('A500000','B500000');
COMMIT;

sqlplus 打印 每个 语句,输出为“创建了 1 行。”

这导致日志非常大且无用...(非常无用...在我们的更改平台上,日志在 50'000 行后被截断...)

如何只记录错误的语句?

仅使用一个 INSERT 语句与所有 VALUES

INSERT into TABLE(OLD,NEW) VALUES
    ('A1','B1'),
    ('A2','B2'),
    ...
    ('A500000','B500000')
;

日志将是 500000 rows created.

在脚本开头添加 set feedback off

SET FEEDBACK OFF also turns off the statement confirmation messages such as 'Table created' and 'PL/SQL procedure successfully completed' that are displayed after successful SQL or PL/SQL statements.

如果您是 运行 non-interactive 会话中的脚本,您可能还想 set echo off