[20190524]sqlplus 与输出&.txt

[20190524]sqlplus 与输出&.txt

--//在sqlplus下 &一般作为参数替换,如何要输出&,一般有几种情况。据说这个问题是asktom站点查看最多的问题。
--//链接:https://connor-mcdonald.com/2018/12/21/your-asktom-top-10-for-2018/

1.要求输出 &.
2.要调用外部命令放入后台执行,而bash shell的后台命令一般在命令后写入 &,这样正好存在冲突。

--//解决方法:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

方法1:
--//临时关闭变量替换。
SCOTT@test01p> SET DEFINE OFF;
SCOTT@test01p> select 'a &b ' from dual ;

'A&B'
----
a &b

方法2:
--//设置另外的字符代替&,例子:
SCOTT@test01p> set define #
SCOTT@test01p> select 'a &b ' from dual ;

'A&B'
-----
a &b

posted @ 2019-05-24 20:43  lfree  阅读(276)  评论(0编辑  收藏  举报