如何假脱机或回显注释Oracle

时间:2019-01-01 14:02:13

标签: oracle shell sqlplus

我是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

2 个答案:

答案 0 :(得分:2)

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

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

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

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

此外,您还应使用spool off结束SQL * Plus脚本。

答案 1 :(得分:0)

您不能将注释后台处理到文件中。但在PL / SQL过程中,您可以使用

DBMS_OUTPUT.PUT_LINE('My comment Line');

或在SqlPlus中

prompt My Comment Line
相关问题