oracle 在假脱机文件中隐藏 SQL > 语句

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30965509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:55:26  来源:igfitidea点击:

Hide SQL > statements in the spool file

oraclesqlplusspool

提问by Haadiya

I want to hide the "SQL> @test.sql" and "SQL> spool off" in the file test.txt(spool file)

我想隐藏文件 test.txt(spool file) 中的“SQL> @test.sql”和“SQL> spool off”

my steps

我的脚步

set heading off 
set pages 0 
set trimspool on 
set lines 120 
set feedback off 
set echo off 
set termout off 
spool test.txt
@test.sql
spool off

test.txt

测试.txt

SQL> @test.sql                              
2002452199  2797    9/1/2014    9/30/2014   OO56128665          934 90087318    1   6046
10226342            ##########  0   0                   


SQL> spool off

采纳答案by Maheswara Raju.Varakavi

reason for getting sql statements into results is:-

将 sql 语句放入结果的原因是:-

    If you copy those sql scripts and paste directly on sql prompt,and execute directly will gets the issues like this. So, to avoid this, place all the script code into one .sql file, and execute that entire file by giving @filename.sql in either "sql command prompt" or in "Dos prompt by logging into sql from Dos".

    如果你复制这些sql脚本并直接粘贴到sql提示符上,直接执行就会出现这样的问题。因此,为避免这种情况,请将所有脚本代码放入一个 .sql 文件中,并通过在“sql 命令提示符”或“通过从 Dos 登录 sql 的 Dos 提示符”中提供 @filename.sql 来执行整个文件。

to avoid the above issue/problem do the following steps:-

为避免上述问题/问题,请执行以下步骤:-

--------------here is my spool_test.sql file code -------------

--------------这里是我的 spool_test.sql 文件代码 -------------

SET echo off
SET feedback off
SET term off
SET pagesize 0
SET linesize 200
SET newpage 0
SET space 0
col name format a120
spool C:\test.txt
@D:\mahesh-plsql-books\spool\test.sql
SPOOL OFF


1) If you execute the above .sql file within SQL> prompt, then it doesn not shows the sql statements along with results in your "test.txt". Like-->

1) 如果您在 SQL> 提示符下执行上述 .sql 文件,那么它不会在您的“test.txt”中显示 sql 语句和结果。喜欢-->

SQL> @D:\mahesh-plsql-books\spool\spool_test2.sql

2) The another way to avoid the "SQL Statements" within the results of "test.txt", is executing the above .sql file with in Dos command prompt(c:>) instead of "sql prompt" like shown below--->

2) 另一种避免“test.txt”结果中出现“SQL 语句”的方法是在 Dos 命令提示符(c:>) 中执行上述 .sql 文件而不是“sql 提示符”,如下所示—— ->

C:\>sqlplus scott/tiger @D:\mahesh-plsql-books\spool\spool_test.sql

......then your "test.txt" does not show the sql statements, as well as @test.sql.

......那么你的“test.txt”不显示sql语句,以及@test.sql。

note:- scott/tiger is my oracle's username/password

注意:- scott/tiger 是我的 oracle 的用户名/密码

Thanks and Regards,
V.Maheswara Raju.

感谢和问候,
V.Maheswara Raju。

回答by doberkofler

This example script (test.sql):

此示例脚本 (test.sql):

set heading off verify off feedback off echo off term off pagesize 0 linesize 10000 trimout on trimspool on timing off
spool test.log
SELECT 'content of spool file' FROM dual;
spool off

when run:

运行时:

>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.1.0 Production on Mon Jun 22 08:46:58 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Last Successful login time: Mon Jun 22 2015 08:46:52 +02:00
Connected to:
Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
SQL> @test.sql
SQL> exit
Disconnected from Oracle Database 12c Release 12.1.0.1.0 - 64bit Production

generates a "clean" spool file:

生成一个“干净”的假脱机文件:

>type test.log
content of spool file