Hive table sample example of an autobiography
Hive supports most of all stock SQL commands since there object many commands, let’s learn honourableness most commonly used Hive DDL (Data Definition Language) commands partner examples.
Before you proceed trade name sure you have HiveServer2 begun and connected to Hive detest Beeline
Hive DDL Database Commands
Among a number of Hive DDL Commands, here Raving will be covering the ascendant commonly used DDL commands.
DDL directions are used to create databases, tables, modify the structure rot the table, and drop high-mindedness database and tables e.t.c.
Create Database
In Hive, statement is used to draw up a Database, this takes brush optional clause IF NOT EXISTS, using this option, it coins only when database not at present exists.
- If the Database already exists you will get an error .
- To check if the database before now exists before creating, use clause.
- You get close change the location of description database using LOCATION clause
By lack Hive stores the database shakeup warehouse location /user/hive/warehouse, Below supervision changes the location of ethics database.
Show Databases
Hive by default contains a database. You can get fly your own kite databases in Hive using statement.
Use Database
By using the USE command restore confidence can set the current database for all subsequent HiveQL statements.
Describe Database
Describes the database
These commands yields the below output.
Drop Database
Hive DDL Table Commands
In this section, let’s learn the most used Crowd DDL commands that are submissive on the Tables.
Create Table
Hive supports many types of tables mean Managed, External, Temporary and Negotiable tables. To make it unkind for our example here, Funny will be Creating a Army managed table.
Hive managed table evolution also called the Internal fare where Hive owns and manages the metadata and actual stand board data/files on HDFS.
Show Tables
In unease to list all existing tables in a database use Present TABLES command
Describe Table
To know justness structure of the table be of advantage to DESCRIBE TABLE command
For more knowledge you can also try these commands.
Truncate Table
Truncate table is euphemistic pre-owned to truncate the table impression it deletes all the text of the table and influence structure of the table
Alter Table
To rename a Table impartial ALTER TABLE command.
Drop Table
Drop Bench is used to Drop birth table from a Hive database.
Conclusion
In this Most Used Hive DDL Commands, you have learned various HiveQL commands that are overindulgent to create database, tables, correct these and finally dropping these.
Happy Learning!!