可以把sql写到脚本里,设置set term off,执行脚本就不打印输出了
[oracle@Centos8 ~]$ cat notprint.sql
set term off
set arraysize 5000
alter session set current_schema=mdd;
set lines 200 pages 200
alter session set statistics_level=all;
set serveroutput off
select * from mdd where rownum<=1000;
[oracle@Centos8 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 11 18:36:26 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> @notprint
SQL> SELECT * FROM table(dbms_xplan.display_cursor('','','allstats last cost'));
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID csprtkzh1m66d, child number 0
-------------------------------------
select * from mdd where rownum<=1000
Plan hash value: 2574202476
--------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers |
--------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 3 (100)| 1000 |00:00:00.01 | 72 |
|* 1 | COUNT STOPKEY | | 1 | | | 1000 |00:00:00.01 | 72 |
| 2 | TABLE ACCESS FULL| MDD | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 72 |
--------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM<=1000)
19 rows selected.
SQL>




