sqlplus打印运行语句 [英] sqlplus print running statement

查看:166
本文介绍了sqlplus打印运行语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有sqlplus可以打印其执行的语句的方法. 我的意思是我有一些在bash脚本中运行的.sql文件.我需要知道什么时候读取日志文件sqlplus运行的日志.

Is there a way where sqlplus can print what statement it executed. I mean I have some .sql files that I run in a bash script. I need to know when I read the log file which statement sqlplus ran.

示例: 说我有这个test.sql文件:

Example: Say I have this test.sql file:

set timing on
create table foo (a varchar2(10));
create table bar (b varchar2(10));
exit

当我查看日志时,得到以下信息:

When I check the log I get this:

Table created.

Elapsed: 00:00:00.02

Table created.

Elapsed: 00:00:00.01

没有提供任何信息.有没有办法可以得到这样的输出:

Which is not informative. Is there a way where I can get output like this:

Table foo created.

Elapsed: 00:00:00.02

Table bar created.

Elapsed: 00:00:00.01

甚至是这样:

create table foo (a varchar2(10));

Table created.

Elapsed: 00:00:00.02

create table bar (b varchar2(10));

Table created.

Elapsed: 00:00:00.01

我知道我可以在每个语句之前使用PROMPT,但是我有很大的sql脚本,在每个语句之前编写PROMPT会很麻烦.

I know I can use PROMPT before each statement but I have big sql scripts and it would be tedious to write PROMPT before each statement.

为使Allan的解决方案始终有效(即,使用"设置回显打开"),您应避免以下情况:

For Allan's solution to always work (i.e. using "set echo on"), you should avoid the following:

1)请勿在sqlplus中使用-S选项,因为这将抑制显示命令回显.

1) Don't use the -S option with sqlplus because this will suppress the display of echoing of commands.

2)不要像这样将您的脚本"cat"到sqlplus:

2) Don't "cat" your script to sqlplus like this:

cat test.sql | sqlplus scott/tiger@orcl

推荐答案

您要查找的命令是SET ECHO ON,它将重复发出的每个语句.

The command you're looking for is SET ECHO ON, which will repeat the each statement that is issued.

这篇关于sqlplus打印运行语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆