简体   繁体   中英

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. When I execute below script I get: COUNT(*) ---------- 100000 I would like to just get: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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