Learn Python
Learn Data Structure & Algorithm
Learn Numpy
Learn Pandas
Learn Matplotlib
Learn Seaborn
Learn Statistics
Learn Math
Learn MATLAB
Learn Machine learning
Learn Github
Learn OpenCV
Learn Deep Learning
Learn MySQL
Learn MongoDB
Learn Web scraping
Learn Excel
Learn Power BI
Learn Tableau
Learn Docker
Hadoop Introduction
Hadoop Hbase
Hadoop HDFS
Hadoop Hive
Hadoop Map Reduce
What is hive?
Hive is tool to process structured data in Hadoop. It is used to summarize big data and makes querying and
analyzing very easy. In Hive we have a query language named HQL. To do querying on the database Hive Query
Language(HQL) is used. Hive is fast, extensible and scalable. Hive is designed for OLTP type database.
How to create and use a database in Hive?
To create a database give command:
Syntax:
CREATE DATABASE database_name;
Example:
CREATE DATABASE StudentInfo;
In Hive there a default database is present. Suppose there is multiple database created.
To select a particular database give command:
USE databse_name;
Example:
USE StudentInfo;
How to create table in hive?
To create a table given commands are used:
CREATE TABLE table_name( columnName columnTypes,columnName columnTypes,columnName columnTypes,....columnName
columnTypes)
ROW FORMAT row_format
FIELDS TERMINATED BY 'delimiter';
Example:
CREATE TABLE student( name string,address string, phoneNumber int, city string)
ROW FORMAT delimited
FIELDS TERMINATED BY ','
stored as textfile;
How to see a table description:
DESCRIBE student;
How to insert data into table?
Let's insert or add data from a file which is stored in HDFS:
Command:
LOAD DATA INPATH 'path' INTO TABLE table_name;
Example:
LOAD DATA INPATH '/hadoopMyFiles/school/student_data.csv' INTO TABLE student;
Note: Here the fields terminated type must be matched with fields terminating delimiter in actual or
main data file. It means the file data must have a delimiter and while creating a table we used delimiter. So
these two delimiter must be same.
How insert data into Hive table?
Syntax:
INSERT INTO TABLE table_name VALUES( value1,value2,value3,...value);
Example:
INSERT INTO TABLE student VALUES( Rafsun,BBRA001,0214311144242,XXXXX);
How to delete data?
If you want to delete the table data only not the table then use TRUNCATE TABLE command.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE student;
If you want to delete the whole table means data and table then use DROP command.
Syntax:
DROP TABLE table_name;
Example:
DROP TABLE student;
It doesn't matter that which technique you are using, in both case the main data file will be also removed
from HDFS.