Skip to content Skip to sidebar Skip to footer

How To Export All Hive Databases And Their Tables To A Csv Or Txt Fiile

I am trying to output all tables in a database to an csv or text file. I can output all the databases by using 'show databases' and I can show all the tables in the databases by us

Solution 1:

You almost reached to an end. just adding up few more details to finish it up!

#!/bin/bash
echo "Executing the shell script"
hive -e "show databases" > databases.txt
for i in `cat databases.txt`
do
    printf "Given database name has below set of tables:"$i >> tableslist.txt
    printf '\n' >> tableslist.txt
    hive -e "show tables in $i" >> tableslist.txt

done
echo "shell scripts ends"

Post a Comment for "How To Export All Hive Databases And Their Tables To A Csv Or Txt Fiile"