I am trying to write a shell script to get the following details - table name and its count. I want both displayed in a csv file. Here is a basic shell script that I started writing. Need help in completing it.
sqlplus -s / as sysdba <<EOF
set line 200
set pages 2000
set echo off feed off head off verify off
spool count.sql
select 'select count(*) from ' || owner ||'.'||table_name||';' from dba_tables where owner in('TEST','COUNTRY');
spool off
spool count.csv
@count.sql
spool off
exit
EOF
when it runs count.sql script, it prints only the record count. How do I append the corresponding table name to it ?
Thanks