Section 6:54. Creating the first table in Hive and List the tables

To create a table in Hive and list all the tables in the current database, you can use the following commands:

  1. Creating a table
Creating Table

Replace table_name, column1_name, column2_name, etc. with the names you want to give your table and its columns. Replace data_type with the appropriate data type for each column (e.g. STRING, INT, DOUBLE, etc.). This command will create a new table with the 

specified columns and data types in the current database.

The ROW FORMAT DELIMITED clause indicates that the data in the table will be in delimited format (i.e. each column value will be separated by a delimiter character). The FIELDS TERMINATED BY ‘,’ clause specifies that the delimiter character will be a comma (,). The STORED AS TEXTFILE clause indicates that the table data will be stored in plain text format.

As part of our labs we will create Orders table 

  1. Listing all tables in the current database:

SHOW TABLES;

This command will display a list of all tables in the current database.

After creating a table, you can insert data into it using the INSERT INTO statement, and you can query the table using the SELECT statement.

Share this post