Hadoop-Hive commands #2

  • date 14th March, 2019 |
  • by Prwatech |
  • 0 Comments
  • To enter the hive shell:

Command:  hive

  • To create a database:

Command: create database prwatech;

  • To see the list of databases:

Command: show databases;

  • To use a particular database to create table:

Command: use prwatech;

  • Move data form 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_Rate

FLOAT) 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 cricketext

(Player_NameSTRING,Runs_ScoredINT,Balls_Face

dINT,Strike_Rate FLOAT) row format delimited

fields terminated by ‘,’ stored as textfile LOCATION

‘/user/cloudera/external’;

  • To insert the data from cricket table to external table cricketext:

Command: from cricket cric insert overwrite table

cricketext select cric.Player_Name,

cric.Runs_Scored, cric.Balls_Faced,cric.Strike_Rate;

  • To see the data in external table:

Command: select * from cricketext;

Leave a Reply

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

Quick Support

image image