Hadoop – How do I get all table definitions in the database in Hive?

I want to get all table definitions in Hive. I know that I can use something similar for single table definitions –

describe <>
describe extended <>

However, I can’t find a way to get all table definitions. Is there something similar to Information_Schema in mysql in megastore Table, or is there a command to get all table definitions?

You can do this by writing a simple bash script and some bash commands.

First, use the following method to write all the table names in the database into a text file:

$hive -e'show tables in ' | tee tables.txt

Then create a bash script (describe_tables.sh) to loop through each table in this list:

while read line 
do
echo "$line"
eval "hive -e'describe .$line'"
done

Then execute the script:< /p>

$chmod +x describe_tables.sh
$./describe_tables.sh definitions.txt

The definitions.txt file will Include all table definitions.

I want to get all table definitions in Hive. I know that for single table definitions I can use something similar –

describe <>
describe extended <>

However, I cannot find a way to get all table definitions. In megastore Is there a table similar to Information_Schema in mysql, or is there a command to get all table definitions?

You can do this by writing a simple bash script and some bash commands.

First, use the following method Write all table names in the database to a text file:

$hive -e'show tables in ' | tee tables.txt

Then create a bash script (describe_tables.sh) to loop through each table in this list:

while read line
do
echo "$ line"
eval "hive -e'describe .$line'"
done

Then execute the script:

$chmod +x describe_tables.sh
$./describe_tables.sh definitions.txt

The definitions.txt file will contain all table definitions.

Leave a Comment

Your email address will not be published.