Updated March 6, 2023
Introduction to Hive Show Tables
Hive is a very important component or service in the Hadoop stack. It will able to handle a huge amount of data i.e. in terms of the TB’s, etc. The data will be store on the distributed manager. In the hive, the actual data will be store on the HDFS level. It is providing the MySQL solution on top of the HDFS data. The hive show tables will print the list of tables which is associated with the current database. But we can’t directly trigger the command on the hive. There is a specific way or with a specific client, we can trigger the command. We can use the JDBC connection (JDBC client) or the ODBC connection (ODBC client).
Syntax of Useradd Command
Syntax of useradd command are given below:
show tables;
- Note: Before running the show table command, we need to select any database to which we need to find the list of tables under the selected database. To select the database in the hive, we need to use or select the database. For that, we need to use the command i.e. “use <database name>”
- show : In the hive service, we need to use a different compatible keyword that we can access the specific database or the table i.e. the show. It will help to get the details about the print or display related operation in the hive environment. With the help of the show keyword, we need to provide one more keyword i.e. the tables. But before triggering the show tables command, we need to select the database. (The note, we have updated the necessary information of it).
- tables : The tables is also an keyword that would be use the with the show keyword. It will help to get the list of table’s related information on the screen. But before running that we need to select the specific database.
How do Show Tables work in Hive?
While working with the hive, we can directly trigger the hive command to fetch the data from the hive. Hive is storing only metadata information. But the actual data is present on the HDFS level. HDFS will manage the actual hive data in the distributed format. When we need to print the hive tables on the screen. First, we need to initiate the connection with the hive service. The connection type will be JDBC or the ODBC type. Once the connection will be established, we need to trigger the command manually or any other way. The hive compiler will check the trigger hive query status by checking the syntax, metadata information availability, etc. If the query is correct then it will process further or the query is not correct then it will through an exception over there. Once the query is correct then it will convert into a logical format. The logical format is known as the dag. The dag will further be allocated to the execution engine. In the hive, we are using a different execution engine. As per the requirement and performance type, we need to choose the execution engine. In the hive, we can use the Tez execution engine or the MapReduce execution engine. The Tez execution engine is faster as compare to the MapReduce execution engine. Here, the working of the Tez execution engine is different as compare to the MapReduce execution engine in terms of the mapper and the executer. Once the dag is allocated to the execution engine, we need resources to run the specific dags. To do so, we need to ask the yarn scheduler to allocate the resources. Once the yarn scheduler will allocate the resources then we can run the necessary dags on the specific datanode. The complete application execution will handle by the nodemanager. Once the query will be executed, we can get the necessary data on the display screen.
Examples of Hive Show Tables Command
Examples to understand hive show tables command are given below:
1. Hive Show Tables: Simple Hive Command
In the hive environment, we are able to get the list of table which is available under the hive database. Before listing the tables, we need to select the database first then only we can list the necessary tables.
Command:
show tables;
Explanation: As per the above command, we are able to get the list of hive table’s i.e. the employee2 table. But as we have discussed we need to select the database first. Here, we have chosen the default database.
Output :
2. Hive Show Tables : With Kerberos
In the Hadoop environment, we are having different security levels like Kerberos, TLS, SSL, etc. As per the security level, we need to act accordingly.
Command:
kinit -kt hive.keytab <hive Kerberos principal name>
Explanation: As per the above command, we are authenticating the hive user with the respective keytab and the principal. Once you will authenticate with the keytab and principal, you will able to generate the Kerberos ticket and able to trigger the hive query.
Output:
3. Hive Show Tables : With Hue
In the hive service, we are able to trigger the show table command from hue also.
Command:
use default;
show tables;
Explanation: As per the above command, we are trigging the command in hue UI. It will give a graphical view. We can get the show tables details on UI.
Output :
4. Hive Show Tables: Get Table Details with Selecting DB
In the hive service, we are having the functionality to get the list of tables without selecting the hive database
Command:
SHOW TABLES FROM DEFAULT;
Explanation: As per the above command, we are getting the list of tables under the default database. Here, we are selecting the database first. We are directly trigging the above command to get the tables from the database.
Output:
Conclusion
We have seen the uncut concept of the “Hive show tables” with the proper example, explanation and command with different outputs. By default, when we need to get the list of tables. We need to select the database first. We have seen the different ways to get the table information like CLI, hue, etc.
Recommended Articles
This is a guide to Hive Show Tables. Here we also discuss the introduction and how to show tables in hive? along with examples. You may also have a look at the following articles to learn more –