<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to get the total number of rows from multiple tables in a database in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32149#M7330</link>
    <description>Right, it was suggested as an optimisation aside of the summing question,&lt;BR /&gt;given the described example. Does the bc command not solve your original&lt;BR /&gt;question?&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Sep 2015 13:19:55 GMT</pubDate>
    <dc:creator>Harsh J</dc:creator>
    <dc:date>2015-09-22T13:19:55Z</dc:date>
    <item>
      <title>How to get the total number of rows from multiple tables in a database?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/31902#M7325</link>
      <description>&lt;P&gt;In my db i have many tables that start with 'bza' in table name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote all those table names into a text file name as&amp;nbsp;&lt;STRONG&gt;tables.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now using a shell script (&lt;STRONG&gt;count_row.sh&lt;/STRONG&gt;) I am reading each line from tables.txt and execuing the hive commnad:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;while IFS='' read -r line || [[ -n "$line" ]]; do
echo ""
echo ""
echo ""
echo "Counting the table : $line"
eval "hive -e 'select count(*) from $line'"
done &amp;lt; "$1"&lt;/PRE&gt;&lt;P&gt;This results in total rows from each table, which I am writting it into a text file rows.txt as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$ ./count_row.sh tables.txt &amp;gt; row.txt&lt;/PRE&gt;&lt;P&gt;Now my task is I want to count the total number of rows from all the tables by summing the individual result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to achieve that ? Or any alternate way to count the rows from mutliple tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:41:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/31902#M7325</guid>
      <dc:creator>Abhinay</dc:creator>
      <dc:date>2022-09-16T09:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32037#M7326</link>
      <description>Should be a simple extension in bash, if that is what you're looking for:&lt;BR /&gt;&lt;BR /&gt;./count_row.sh tables.txt | paste -s -d+ - | bc&lt;BR /&gt;&lt;BR /&gt;Ref: &lt;A href="http://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line#comment12469220_451204" target="_blank"&gt;http://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line#comment12469220_451204&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;P.s. It may be more efficient to generate a list of queries and run it via a single hive command, cause each command runs a whole new JVM.</description>
      <pubDate>Sun, 20 Sep 2015 14:37:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32037#M7326</guid>
      <dc:creator>Harsh J</dc:creator>
      <dc:date>2015-09-20T14:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32128#M7327</link>
      <description>&lt;P&gt;@Harsh J&lt;BR /&gt;By saying "Generate a list of queries" you mean, creating a list of queries and separate by ;(semicolon) in hive command like&lt;BR /&gt;hive -e 'query1;query2;...queryN' ?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2015 08:39:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32128#M7327</guid>
      <dc:creator>Abhinay</dc:creator>
      <dc:date>2015-09-22T08:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32129#M7328</link>
      <description>Yes that could work too (or a file with them, passed via -f or such).</description>
      <pubDate>Tue, 22 Sep 2015 09:26:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32129#M7328</guid>
      <dc:creator>Harsh J</dc:creator>
      <dc:date>2015-09-22T09:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32147#M7329</link>
      <description>@Harsh J&lt;BR /&gt;Using hive -f a file can be passed, but the main purpose of writing the loop in script is to automate the process. I have to apply the same command for 250 tables.</description>
      <pubDate>Tue, 22 Sep 2015 13:17:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32147#M7329</guid>
      <dc:creator>Abhinay</dc:creator>
      <dc:date>2015-09-22T13:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32149#M7330</link>
      <description>Right, it was suggested as an optimisation aside of the summing question,&lt;BR /&gt;given the described example. Does the bc command not solve your original&lt;BR /&gt;question?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Sep 2015 13:19:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32149#M7330</guid>
      <dc:creator>Harsh J</dc:creator>
      <dc:date>2015-09-22T13:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32161#M7331</link>
      <description>I was just asking it. yes it solved using bc</description>
      <pubDate>Tue, 22 Sep 2015 17:05:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32161#M7331</guid>
      <dc:creator>Abhinay</dc:creator>
      <dc:date>2015-09-22T17:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32162#M7332</link>
      <description>Glad to know! Please consider marking the thread resolved, so others with a&lt;BR /&gt;similar question can find a solution quicker.&lt;BR /&gt;&lt;BR /&gt;Feel free to post a new thread with any further questions.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Sep 2015 17:17:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/32162#M7332</guid>
      <dc:creator>Harsh J</dc:creator>
      <dc:date>2015-09-22T17:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/54455#M7333</link>
      <description>&lt;P&gt;It doesn't work for me, here is the screenshot:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot - 5_5_2017 , 9_23_33 PM.jpg" style="width: 506px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/2965i735C6414B5FE9927/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot - 5_5_2017 , 9_23_33 PM.jpg" alt="Screenshot - 5_5_2017 , 9_23_33 PM.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 01:22:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/54455#M7333</guid>
      <dc:creator>PasLeChoix</dc:creator>
      <dc:date>2017-05-06T01:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the total number of rows from multiple tables in a database?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/93574#M7334</link>
      <description>&lt;P&gt;Done keyword is missing in your script. In your loop body use done at last.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 11:26:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-get-the-total-number-of-rows-from-multiple-tables-in/m-p/93574#M7334</guid>
      <dc:creator>SatyamKumar</dc:creator>
      <dc:date>2019-07-31T11:26:32Z</dc:date>
    </item>
  </channel>
</rss>

