Hadoop Hive Basic Commands, are you looking for a list of Top Rated Hive commands in Hadoop technology? Or the one who is casually glancing for the best platform which is listing the Hadoop Hive Commands with examples for beginners? Then you’ve landed on the Right Platform which is packed with Tons of Tutorials of Hive commands in Hadoop. Follow the below mentioned Hadoop Hive commands for Beginners which were originally designed by the world-class Trainers of Hadoop Training institute Professionals.
If you are the one who is a hunger to become the certified Pro Hadoop Developer? Or the one who is looking for the best Hadoop Training institute which offering advanced tutorials and Hadoop certification course to all the tech enthusiasts who are eager to learn the technology from starting Level to Advanced Level.
Hadoop Hive Commands with Examples
Create Database
Using below given command we create a database.
Show Database: Using the below-given command we can list all databases.
Use Database: Using below given command we can use a particular database.
Drop Database: Using the below-given command we can remove a particular database.
Create Table: Using the below command create a table with multiple columns and describing datatype of each column.
Select Command: To display a record from the selected table.
Describe table: Using the below command we can describe the property of a table.
Alter: Alter command is used to add or to make changes in current table property.
Adding Column: Using below given command we can new column in our existing table.
FLIGHT INFORMATION
To enter the hive shell:Command: hiveTo select a particular database:Command: use prwatech;Create table flightinfo2008:Command: create table flightinfo2008(Year SMALLINT, Month TINYINT, DayofMonth TINYINT,DayOfWeek TINYINT,DepTime SMALLINT,CRSDepTime SMALLINT, ArrTime SMALLINT,CRSArrTime SMALLINT,UniqueCarrier STRING,FlightNum STRING, TailNum STRING,ActualElapsedTime SMALLINT, CRSElapsedTimeSMALLINT,AirTime SMALLINT, ArrDelaySMALLINT, DepDelay SMALLINT,Origin STRING,DestSTRING,Distance INT,TaxiIn SMALLINT,TaxiOut SMALLINT, CancelledSMALLINT,CancellationCode STRING, DivertedSMALLINT,CarrierDelay SMALLINT, WeatherDelaySMALLINT,NASDelay SMALLINT, SecurityDelaySMALLINT,LateAircraftDelaySMALLINT)COMMENT'Flight InfoTable' ROW FORMAT DELIMITEDFIELDS TERMINATED BY ','LINES TERMINATED BY '\n'STORED AS TEXTFILETBLPROPERTIES ('creator'='Bruce Brown', 'created_at'='Thu Sep 19 10:58:00 EDT 2013');To load data in the table:Command: LOAD DATA LOCAL INPATH '/home/cloudera/Desktop/2008.csv' INTO TABLE flightinfo2008;To create table myflightinfo:Command: create table myflightinfo(YearSMALLINT, DontQueryMonth TINYINT, DayofMonthTINYINT, DayOfWeek TINYINT,DepTime SMALLINT,ArrTime SMALLINT,UniqueCarrier STRING,FlightNum STRING,AirTime SMALLINT, ArrDelaySMALLINT, DepDelay SMALLINT,Origin STRING,Dest STRING, Cancelled SMALLINT,CancellationCodeSTRING)COMMENT 'FlightInfoTable'PARTITIONEDBY(Month TINYINT)ROW FORMAT DELIMITEDFIELDS TERMINATED BY ','LINES TERMINATED BY'\n' STORED AS RCFILETBLPROPERTIES('creator'='Bruce Brown', 'created_at'='MonSep 2 14:24:19 EDT 2013');To load partition data in my flight info from flightinfo2008:Command: FROM FlightInfo2008INSERT INTO TABLE my flight infoPARTITION (Month=2)SELECT Year, Month, DayofMonth, DayOfWeek, DepTime,ArrTime, UniqueCarrier, FlightNum,AirTime, ArrDelay, DepDelay, Origin, Dest, Cancelled,CancellationCode WHERE Month=2;To see which partitioned data is stored:Command: SHOW PARTITIONS my flight info;To create table myflightinfo2008:Command: CREATE TABLE myflightinfo2008 ASSELECT Year, Month, DepTime, ArrTime, FlightNum,Origin, Dest FROM FlightInfo2007WHERE (Month =7 AND DayofMonth = 3) AND (Origin='JFK' ANDDest='ORD');To see the data in myflightinfo2008:Command: SELECT* FROM myflightinfo2008;
Hadoop Hive commands for Beginners
To enter the Hive shell:Command: hiveTo create a database:Command: create database prwatech;To see the list of databases:Command: show databases;To use a particular database to create a table:Command: use prwatech;Move data from lfs to hdfs:Command: Hadoop fs -copyFromLocal ‘--LOCATION OR PATH OF DOCUMENT--’ /user/Cloudera (On new terminal)Create a table:Command: create table cricket (Player_NameSTRING,Runs_ScoredINT,Balls_FacedINT,Strike_RateFLOAT) row format delimited fields terminated by ‘,’stored as textfile;To load data into the table:Command: LOAD DATA INPATH '/user/cloudera/cricketdoc.txt' OVERWRITE INTO table cricket;To create an external table:Command: create external table cricket text(Player_NameSTRING,Runs_ScoredINT,Balls_FacedINT, Strike_Rate FLOAT) row format delimitedfields terminated by ‘,’ stored as textfile LOCATION‘/user/Cloudera/external’;To insert the data from the cricket table to external table cricket text:Command: from cricket cric insert overwrite tablecricket text select cric.Player_Name,cric.Runs_Scored, cric.Balls_Faced,cric.Strike_Rate;To see the data in the external table:Command: select * from cricket text;
Get success in your career as a Hadoop developer by being a part of the Prwatech, India's leading Hadoop training institute in Bangalore.