简体   繁体   English

oracle行计入shell脚本变量

[英]oracle row count into shell script variable

I want to get count of oracle table into shell variable so I can compare to row count in csv file and make sure record counts match. 我想把oracle表计入shell变量,这样我就可以比较csv文件中的行数,并确保记录计数匹配。 When I execute below script I get: COUNT(*) ---------- 100000 I would like to just get: 100000 当我执行下面的脚本时,我得到:COUNT(*)---------- 100000我想得到:100000

What are good approaches? 什么是好方法?

VAR="$(sqlplus -S usr/pw@//host:1521/db <<ENDOFSQL
select count(*) from table;
exit;
ENDOFSQL)"  
echo $VAR

Try this, 尝试这个,

VAR="$(sqlplus -S usr/pw@//host:1521/db <<ENDOFSQL
set head off
select count(*) from table;
exit;
ENDOFSQL)"  
echo $VAR

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM