Introduction

Hive is a query language, which was developed by Facebook. Hadoop can give support to any kind of data.
Hadoop supports HiveQL.
Difference between SQL & HiveQL
In Hive, every table is created as a directory.
HQL datatypes
Like other RDBMS (Oracle, MySQL, SQL Server), it also has databases.
TinyInt Float Map
ShortInt Double Array
BigInt String Struct
Here map, array, struct are called collection datatypes.
Creating hive tables
Hive tables can be created in two ways.
  1. Managed tables or Internal tables.
  2. External tables.
Managed tables or Internal tables
  • user@machine:~$ hive
  • hive> create table employee(id int, name string,salary float)
  • >row format delimited
  • >fields terminated by ‘\t’;
Important points
Loading data into Hive tables
The data can be loaded in two ways.
Either from the local file system or from HDFS
Loading data from the local file system
hive>load data local inpath <filepath> into table <tablename>
Loading data from HDFS
hive>load data inpath <filepath> into table <tablename>
Here, we will hear a few words like metadata, which means the data about the data & metastore, which means keeping metadata to store.
External Tables
hive> create external table employeeE(id int, name string,salary float),
  • >row format delimited
  • >fields terminated by ‘\t’
  • >location “/vimal/newfolder”;
Concept
Internal Table
/user / hive / warehouse
employee (directory)
employee (file)
employee1 (file)
External Table
/vimal / newfolder /
employee (file)