Oracle SQLPlus:如何显示SQLPlus命令的输出,而不必首先发出假脱机命令?

时间:2021-09-23 21:41:50

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

谢谢

5 个解决方案

#1


1  

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.

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

#2


2  

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 TOAD and 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的TOAD和Allround Automation的PL/SQL Developer,但是如果您不想要支付许可费,那么您应该看看Oracle自己的(免费的)SQL Developer。

#3


1  

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.

如果您的问题是无法打开输出文件(因为spool进程有一个锁),那么尝试将文件输出复制到另一个文件并打开该文件。

#4


1  

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开始输出看起来更好?那么你可能根本不需要欺骗。

#5


0  

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.

在其他情况下,我会使用sqlplus而不是sqldeveloper,因为我需要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.

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

Thanks

谢谢

#1


1  

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.

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

#2


2  

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 TOAD and 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的TOAD和Allround Automation的PL/SQL Developer,但是如果您不想要支付许可费,那么您应该看看Oracle自己的(免费的)SQL Developer。

#3


1  

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.

如果您的问题是无法打开输出文件(因为spool进程有一个锁),那么尝试将文件输出复制到另一个文件并打开该文件。

#4


1  

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开始输出看起来更好?那么你可能根本不需要欺骗。

#5


0  

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.

在其他情况下,我会使用sqlplus而不是sqldeveloper,因为我需要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.

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

Thanks

谢谢