• Call us: +91 9501707741
  • tutorialzdiary@gmail.com


HADOOP Tutorials

Chapter 1 : Introduction
Chapter 2 : What is Hadoop ?
Chapter 3 : HDFS
Chapter 4: HDFS Security
Chapter 5 : Sqoop
Chapter 6 : Apache Pig

HADOOP Hands on

Hadoop 1 : Ingesting Data into Hadoop Through Sqoop
Hadoop 2 : Basics of Apache Hive
Hadoop 2.1 : Apache Hive Tables
Hadoop 3: Basics of Apache Pig
Hadoop 4 : Basics of Apache HBase

HADOOP Interview Questions and Answers

Part 1 : Big Data Basics
Part 2 : MapReduce
Part 3 : Mapreduce II
Part 4 : Hive I
Part 5 : Hive II
Part 6 : Hbase I

HADOOP Training

BigData and Hadoop Training Course

Hadoop 2.1 : Apache Hive Tables

In this section we are going to cover the following :-

  1. Type of tables
  2. Creating views

Type of Tables : You can have Managed table and External Table in Hive.

(i) Managed Table :

Managed tables are like normal database tables if you drop the table both  data and the table will no longer present in your Database. Internal tables get stored in the directory “/user/hive/warehouse” by default it can be changed by updating the location in the config “hive.metastore.warehouse.dir“.
Managed table also goes by the name “Internal table“.

Use : When you want Hive to manage the lifecycle of your table and data.

Creating a Managed Table

Creating a Managed Table

How to know the table is Managed table or External table . Use Command ” DESC FORMATTED ‘< table name >’ “.

Checking the type of table in Hive

Checking the Type of Table in Hive

(ii) External Table :

External Tables are the table which is stored in HDFS. If you drop your external table, the table will be dropped but data will be still there in HDFS. This is because Hive maintains its metadata on the master node, therefore, the deleting  of table won’t delete the data.

To create external table . Use command :

CREATE EXTERNAL TABLE <table name>  ( col datatype ) LOCATION ‘/hdfs/’;

Use : The Table and data used  by many processes like ETL etc.

Creating External Table in Hive

Creating External Table in Hive

Checking the table information :-

Checking Type of Table in Hive

Checking Type of Table in Hive

2 . VIEW in Hive :

View is another feature close to relation database View. View is logical object build to query data by hiding away its complex queries like where clause , sub-joins, and other filter conditions. In Hive, a view  never stores the data like the table.

You can create a View following ways :

CREATE VIEW <Viewname> AS SELECT <columns > FROM <table name>;

CREATE VIEW <viewname> AS SELECT * FROM <tab1> JOIN <tab2> ON <conditon>;

We already have one table which contains data of employs Id , name, and their salary.

Creating View in Hive

Creating View in Hive

Lets Query the View :

Views in Hive

Views in Hive

View data in Hive which contains only select values.

View data in Hive which contains only select values.


Leave a reply

Your email address will not be published. Required fields are marked *

Training Enquiry