当我跑(通过Mac客户端远程)时:
echo "select table_name from user_tables" | sqlplus 'myuser/mypass@myhost.com:myport/mysid'
我没有显示数据:
SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 2 15:12:57 2016
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> 2 Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
但是我知道它有效,因为当我以交互模式运行它(即没有管道)时,我确实得到了数据:
SQL> select count(*) from user_tables;
COUNT(*)
----------
353
我没有login.sql
所以我希望它能展示一些东西,即使它很难看。
我做错了什么?
答案 0 :(得分:0)
我怀疑,这是一个小问题。不要忘记你必须完全模仿你在解释器中输入的内容 - 包括分号:
echo "select table_name from user_tables;" | sqlplus 'myuser/mypass@myhost.com:myport/mysid'
如果您想添加格式选项,请按交互式方式执行操作:
echo "set pages 200\n select table_name from user_tables;" | sqlplus 'op_qa_zact/saas_admin@odb-scan.di01.qa.itsonsaas.com:1520/QADB01'