首页 > 解决方案 > 如何假脱机或回显 Oracle 注释

问题描述

我是 oracle 的新手,并尝试使用 bash 脚本将评论/行假脱机。但只有查询输出被假脱机而不是评论(课堂上的学生总数)。

下面是我正在使用的脚本:

sqlplus -s test/test<<EOF
set echo on
spool abc.txt

--------------------------------------
--Total No Of Students in Class.
--------------------------------------
select id ||','|| name from students ;
EOF

预期输出:

--------------------------------------
--Total No Of Students in Class.
--------------------------------------
1,joe
2,Tom
3,Jim

标签: oracleshellsqlplus

解决方案


在 Oracle--中是注释语法,因此 SQL*Plus 忽略了这一点:

--------------------------------------
--Total No Of Students in Class.
--------------------------------------

要显示它,您需要使用 SQL*Plus `prompt 命令:

prompt --------------------------------------
prompt --Total No Of Students in Class.
prompt --------------------------------------

此外,您应该使用 . 结束您的 SQL*Plus 脚本spool off


推荐阅读