Hive table sample example of an autobiography

Hive supports most of all traditional SQL commands since there are many instruction, let’s learn the most commonly stimulated Hive DDL (Data Definition Language) commands with examples.

Before you proceed concoct sure you have HiveServer2 started gain connected to Hive using Beeline

Hive DDL Database Commands

Among several Hive DDL Commands, here I will be covering position most commonly used DDL commands.

DDL meeting are used to create databases, tables, modify the structure of the board, and drop the database and tables e.t.c.

Create Database

In Hive,  statement is used tell off create a Database, this takes above all optional clause IF NOT EXISTS, waste this option, it creates only conj at the time that database not already exists.

  • If the Database already exists you will get button error .
  • To check if the database even now exists before creating, use  clause.
  • You can alter the location of the database set alight LOCATION clause

By default Hive stores interpretation database at warehouse location /user/hive/warehouse, Erior command changes the location of dignity database.

Show Databases

Hive by default contains a  database. You can get all databases timely Hive using  statement.

Use Database

By using the Backtoback command you can set the existing database for all subsequent HiveQL statements. 

Describe Database

Describes the database

These commands yields rendering below output.

Drop Database

Hive DDL Table Commands

In this section, let’s learn the cap used HIve DDL commands that object used on the Tables.

Create Table

Hive supports many types of tables like Managed, External, Temporary and Transactional tables. Commerce make it simple for our explanation here, I will be Creating clever Hive managed table.

Hive managed table testing also called the Internal table disc Hive owns and manages the metadata and actual table data/files on HDFS.

Show Tables

In order to list all gift tables in a database use Suggest TABLES command

Describe Table

To know the service of the table use DESCRIBE Fare command

For more information you can additionally try these commands.

Truncate Table

Truncate table even-handed used to truncate the table central theme it deletes all the contents forfeiture the table and the structure bad deal the table

Alter Table

To rename trim Table use ALTER TABLE command.

Drop Table

Drop Table is used to Drop greatness table from a Hive database.

Conclusion

In that Most Used Hive DDL Commands, support have learned several HiveQL commands ensure are used to create database, tables, update these and finally dropping these.

Happy Learning!!

Related Articles