Oracle SQLPlus:如何在不必先发出 spool off 命令的情况下显示 sqlplus 命令的输出?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3013805/
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-18 20:47:40  来源:igfitidea点击:

Oracle SQLPlus: How to display the output of a sqlplus command without having to first issue the spool off command?

sqloraclesqlplus

提问by ziggy

Is there a way to display the output of a sqlplus command without having to first issue the spool off command?

有没有办法显示 sqlplus 命令的输出而不必先发出 spool off 命令?

I am spooling the results of a sqlplus session to a file while at the same time tailing the file. The reason for this is that for table with very long rows the format is easier to look at from a file. The problem is to see the output i have to issue the spool off command everytime i run a command in sqlplus.

我正在将 sqlplus 会话的结果假脱机到文件,同时拖尾文件。这样做的原因是对于行很长的表,格式更容易从文件中查看。问题是要查看输出,每次我在 sqlplus 中运行命令时,我都必须发出 spool off 命令。

Can i configure sqlplus so that after i have issued the spool command all the output is viewable straight away on the file.

我可以配置 sqlplus 以便在我发出 spool 命令后,所有输出都可以立即在文件中查看。

(Formating the way the rows are displayed on the screen is not an option. )

(格式化行在屏幕上的显示方式不是一种选择。)

THanks

谢谢

采纳答案by Leigh Riffel

If you are spooling the results of multiple statements you could turn spooling off and then turn it back on between each statement. When you turn spooling back on add the append keyword so that it will continue in the same file rather than overwriting it.

如果您正在假脱机处理多个语句的结果,您可以关闭假脱机,然后在每个语句之间重新打开它。当您重新打开假脱机时,添加 append 关键字,以便它在同一个文件中继续而不是覆盖它。

If you want to see the results of one query in your spool file you could break the query up into multiple queries that returned specific ranges of the data. This would be slower, but you could cycle spooling to get faster feedback.

如果您想在假脱机文件中查看一个查询的结果,您可以将该查询分解为多个返回特定数据范围的查询。这会更慢,但您可以循环假脱机以获得更快的反馈。

回答by APC

SPOOL is really intended for creating a file of SQL*Plus output, for whatever purpose: logging, input to another process, etc. There is no facility for inflight viewing of its output.

SPOOL 真正用于创建 SQL*Plus 输出文件,无论出于何种目的:记录、输入到另一个进程等。没有用于在飞行中查看其输出的工具。

There are a number of ways of solving this particular problem, but the easiest is surely to use an IDE which includes a data browser, thus obviating the need to tail a file. There are a number on the market, including Quest's TOADand Allround Automation's PL/SQL Developer, but if you don't want to spring for a license fee then you should have a look at Oracle's own (free) SQL Developer.

有多种方法可以解决这个特定问题,但最简单的方法肯定是使用包含数据浏览器的 IDE,从而避免拖尾文件的需要。市场上有很多,包括Quest 的 TOADAllround Automation 的 PL/SQL Developer,但如果您不想支付许可费,那么您应该看看Oracle 自己的(免费)SQL Developer

回答by APC

If your problem is that you can't open the output file (as the spool process has a lock on it) then try copying the file output to another file and opening that file instead.

如果您的问题是无法打开输出文件(因为假脱机进程对其有锁定),请尝试将文件输出复制到另一个文件并打开该文件。

回答by Dave Costa

Since it sounds like your real problem is formatting of output in SQLPlus -- can you make your SQLPlus window wider and SET LINESIZE so the output looks better in SQLPlus to start with? Then you might not need to spool at all.

因为听起来您真正的问题是在 SQLPlus 中格式化输出——您能否使您的 SQLPlus 窗口更宽并设置 LINESIZE 以便开始时在 SQLPlus 中的输出看起来更好?那么你可能根本不需要假脱机。

回答by ziggy

I tried to add a comment but for some reason it doesnt save it so ill try the "Answer your question" option :)

我试图添加评论但由于某种原因它没有保存它所以我尝试“回答你的问题”选项:)

I do use SQLDeveloper but there are situations where i have to use sqlplus where SQLDeveloper is not available then i am stuck with plain old sqlplus.

我确实使用 SQLDeveloper,但在某些情况下,我必须使用 sqlplus,而 SQLDeveloper 不可用,然后我就只能使用普通的旧 sqlplus。

There are other situations where i would use sqlplus over sqldeveloper purely for the fact that it would take me 1/2 minute to find out what i am looking for in sqlplus rather than several minutes with SQLDeveloper as it would take ages to load.

在其他情况下,我会在 sqldeveloper 上使用 sqlplus 纯粹是因为我需要 1/2 分钟才能在 sqlplus 中找到我要查找的内容,而不是使用 SQLDeveloper 几分钟,因为加载需要很长时间。

I have checked the time it takes before the output is flushed out and it looks like it does flush it out after a certain number of rows. Isnt there a way to reduce the buffer so that they are flushed out quicker?

我已经检查了输出被刷新之前所花费的时间,看起来它确实在一定数量的行之后刷新了它。有没有办法减少缓冲区,以便更快地清除它们?

There is no problem opening the file the problem is even with the file opened i cant see the output unless i issue the "spool off" command or the output has several hundred rows. I am using a free program called baretail (http://www.baretail.com) to tail the spool file on windows.

打开文件没有问题,问题是即使打开文件我也看不到输出,除非我发出“spool off”命令或输出有几百行。我正在使用一个名为 baretail ( http://www.baretail.com)的免费程序来跟踪windows 上的假脱机文件。

Thanks

谢谢