在没有oracle header / footer的情况下将sqlresult转换为bash变量

时间:2013-03-27 16:14:26

标签: sql bash sqlplus

#!/bin/bash -x

x=`sqlplus scott/tiger@xe<<endl
set heading off
select sysdate from dual;
exit
endl`

echo the answer is $x

正在输出

the answer is SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 27 09:01:25 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> SQL> 27-MAR-13 SQL> Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Productiong 

我想要的只是查询sysdate的结果。我如何摆脱所有的oracle relase,copyright,... info。

1 个答案:

答案 0 :(得分:0)

我找到了答案

sqlplus -s
然后

将删除标题