-1

我运行以下命令连接到远程数据库:

/bin/sql user/pass@delphix-1.test.com:1521:vd4

我想运行它,但查询包含在一行中。

我尝试在 vdbsl4 之后添加一个空格和查询,但这不起作用(我认为它只是给了我一个关于如何使用 sqlcl 的说明的错误)。

如果可能的话,我怎样才能在一行中完成连接+查询?

4

2 回答 2

0

尝试

echo "SELECT 1 FROM DUAL" | sql usrnm/psw@myhost.com:1521:starter

PD:对于那些使用服务名称而不是SID的人,请记住替换:starter/ORCL(给定默认安装值,否则显然将它们替换为您的数据库参数)

于 2019-11-30T22:10:12.520 回答
0

你可以试试 STDin

`$sql barry/oracle << EOF
 select user from dual;
 EOF`

SQLcl: Release 12.2.0.1.0 RC on Mon Aug 08 18:29:09 2016

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Mon Aug 08 2016 18:29:10 +01:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

USER   

BARRY  


BARRY@orcl☘ >
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

再次回来,您可以将其呼应,以获得真正的单线体验。

C:\TMP>echo select 1 from dual|\software\sqlcl\bin\sql barry/oracle@localhost:1521/xe

SQLcl: Release 17.2.0 Production on Tue Aug 29 18:13:40 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production



         1
----------
         1

SQL>

SQL>
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

C:\TMP>
于 2016-08-08T17:35:45.873 回答