We can load data into hive table in three ways.Two of them are DML operations of Hive.Third way is using hdfs command.If we have data in RDBMS system like Oracle,Mysql,DB2 or SQLServer we can import it using SQOOP tool.That Part we are not discussing now.
To Practice below commands ,create a table called Employee with below data
eno,ename,salary,dno
11,Balu,100000,15
12,Radha,120000,25
13,Nitya,150000,15
14,Sai Nirupam,120000,35
1. Using Insert Command
We can load data into a table using Insert command in two ways.One Using Values command and other is using queries.
1.1 Using Values
Using Values command ,we can append more rows of data into existing table.
for example ,to existing above employee table we can add extra row 15,Bala,150000,35 like below
Insert into table employee values (15,'Bala',150000,35)
After this You can run a select command to see newly added row.
1.2 Using Queries
You can also upload query output into a table.for example Assume you have emp table,from this, you can upload data into employee table like below
Insert into table employee Select * from emp where dno=45;
After this also You can fire select query to see uploaded rows.
2.Using Load
You can load data into a hive table using Load statement in two ways.
One is from local file system to hive table and other is from HDFS to Hive table.
2.1 From LFS to Hive Table
Assume we have data like below in LFS file called /data/empnew.csv.
15,Bala,150000,35
Now We can use load statement like below.
Load data local inpath '/data/empnew.csv' into table emp
2.2 From HDFS to Hive Table
if we do not use local keyword ,it assumes it as a HDFS Path.
Load data inpath '/data/empnew.csv' into table emp
After these two statements you can fire a select query to see loaded rows into table.
3. Using HDFS command
Assume You have data in a local file,You can simply upload data using hdfs commands.
run describe command to get the location of table like below.
describe formatted employee;
It will display Location of the table ,Assume You got location as /data/employee, you can upload data into table by using one of below commands.
hadoop fs -put /path/to/localfile /Data/employee
hadoop fs -copyFromLocal /path/to/localfile /Data/employee
hadoop fs -moveFromLocal /path/to/localfile /Data/employee
To Practice below commands ,create a table called Employee with below data
eno,ename,salary,dno
11,Balu,100000,15
12,Radha,120000,25
13,Nitya,150000,15
14,Sai Nirupam,120000,35
1. Using Insert Command
We can load data into a table using Insert command in two ways.One Using Values command and other is using queries.
1.1 Using Values
Using Values command ,we can append more rows of data into existing table.
for example ,to existing above employee table we can add extra row 15,Bala,150000,35 like below
Insert into table employee values (15,'Bala',150000,35)
After this You can run a select command to see newly added row.
1.2 Using Queries
You can also upload query output into a table.for example Assume you have emp table,from this, you can upload data into employee table like below
Insert into table employee Select * from emp where dno=45;
After this also You can fire select query to see uploaded rows.
2.Using Load
You can load data into a hive table using Load statement in two ways.
One is from local file system to hive table and other is from HDFS to Hive table.
2.1 From LFS to Hive Table
Assume we have data like below in LFS file called /data/empnew.csv.
15,Bala,150000,35
Now We can use load statement like below.
Load data local inpath '/data/empnew.csv' into table emp
2.2 From HDFS to Hive Table
if we do not use local keyword ,it assumes it as a HDFS Path.
Load data inpath '/data/empnew.csv' into table emp
After these two statements you can fire a select query to see loaded rows into table.
3. Using HDFS command
Assume You have data in a local file,You can simply upload data using hdfs commands.
run describe command to get the location of table like below.
describe formatted employee;
It will display Location of the table ,Assume You got location as /data/employee, you can upload data into table by using one of below commands.
hadoop fs -put /path/to/localfile /Data/employee
hadoop fs -copyFromLocal /path/to/localfile /Data/employee
hadoop fs -moveFromLocal /path/to/localfile /Data/employee
In 2.2 section that is From HDFS to Hive tables the query that given is wrong. it should not contain Keyword "LOCAL".
ReplyDeleteLoad data inpath '/data/empnew.csv' into table emp
Thank Jeffin, it is Updated.
Deleteif we load emp data into table as line string,from emp if want to extract to only name and salary from emp,how to extract..............
ReplyDeleteselect name,salary from emp;
DeleteHi,I have a .dat file and I do not know how many columns it has, how do I load the file in Hive without Hive Table?
ReplyDeletehi Balaswamy, thanks for creating such informative blog for us , i am referring your blogs since long , as an hadoop admin this is very much helpful for me ,
ReplyDeleteif u have any specific doc for HAdoop integration with corporate AD and other open source tool please update here
thanks and regards
sonali
Hi, when i am trying to take the full path. Its throwing below error.
ReplyDeletePath is not legal \'"D:/dn/file/DEV/test/final_file.csv"\': Source file system should be "file" if "local" is specified.
Can you please help me in keeping the whole path.
Aivivu chuyên vé máy bay, tham khảo
ReplyDeleteCác chuyến bay từ Incheon về Hà Nội hôm nay
mua vé máy bay hà nội đi sài gòn
giá vé máy bay đi hà nội vietnam airline
hà nội nha trang
vé máy bay đi Mỹ giá rẻ 2021
In the context of Apache Hive, a Hive table refers to a structured data storage unit managed by Hive, which is built on top of Apache Hadoop. Hive provides a mechanism to query and manage large datasets stored in Hadoop's distributed file system (HDFS) or other compatible storage systems using a SQL line language called HiveQL.
DeleteBig Data Projects For Final Year
instead of create and load data simply create external table based on location its easy and recommended approach
ReplyDeleteThanks & Regards
Venu
bigdata hadoop training in Hyderabad
What an interesting post. This is so useful. www.carypavers.com
ReplyDeleteGood article about hadoop technology You may like Updated content at Hadoop Quiz all about hadoop
ReplyDeletevan
ReplyDeletezonguldak
yalova
urfa
gümüşhane
SDU6ME
giresun evden eve nakliyat
ReplyDeletebalıkesir evden eve nakliyat
maraş evden eve nakliyat
kastamonu evden eve nakliyat
kocaeli evden eve nakliyat
JVOPİ
92F9F
ReplyDeleteSiirt Parça Eşya Taşıma
Yozgat Parça Eşya Taşıma
Mardin Evden Eve Nakliyat
Çanakkale Parça Eşya Taşıma
Adana Lojistik
0E66B
ReplyDeleteÇankırı Evden Eve Nakliyat
Artvin Evden Eve Nakliyat
Ankara Asansör Tamiri
Maraş Evden Eve Nakliyat
Tekirdağ Cam Balkon
65572
ReplyDeleteBingöl Lojistik
Çankırı Parça Eşya Taşıma
Bilecik Evden Eve Nakliyat
Bingöl Parça Eşya Taşıma
Wabi Coin Hangi Borsada
Ünye Yol Yardım
Etimesgut Fayans Ustası
Batman Şehirler Arası Nakliyat
Balıkesir Şehir İçi Nakliyat
EB1F0
ReplyDeletetrabzon mobil sohbet et
zonguldak ücretsiz sohbet siteleri
mobil sohbet et
ücretsiz sohbet uygulamaları
istanbul goruntulu sohbet
kırşehir canli goruntulu sohbet siteleri
mobil sohbet
mardin telefonda sohbet
kırıkkale görüntülü sohbet uygulamaları ücretsiz
23825
ReplyDeleteElazığ Goruntulu Sohbet
Karaman Görüntülü Sohbet
kayseri rastgele sohbet
diyarbakır sesli sohbet siteleri
siirt parasız sohbet
yabancı görüntülü sohbet siteleri
Bayburt Parasız Görüntülü Sohbet Uygulamaları
erzurum sesli sohbet siteler
çankırı yabancı canlı sohbet
B4713
ReplyDeleteBinance Referans Kodu
Kwai Takipçi Hilesi
Linkedin Takipçi Hilesi
Twitter Trend Topic Hilesi
Facebook Takipçi Hilesi
Görüntülü Sohbet
Spotify Takipçi Hilesi
Nexa Coin Hangi Borsada
Telcoin Coin Hangi Borsada
91656
ReplyDeletekızlarla canlı sohbet
kaldıraç ne demek
btcturk
bitexen
bingx
toptan mum
okex
filtre kağıdı
mexc
9FABD
ReplyDeletebitcoin ne zaman çıktı
bitcoin hangi bankalarda var
bitget
coin nasıl alınır
referans kimliği nedir
cointiger
kraken
kripto ne demek
bitcoin ne zaman yükselir
90B3A
ReplyDeleteiç mimar
ehliyet sınav soruları
Google Harita & İşletme Kaydı
İçerik Editörü (Makale Yazarı)
Backlink Satın Al
Tanıtım Yazısı
Silkroad Pvp
fuar standı
seo nedir
B47E0
ReplyDeletejeneratör fiyatları
fuar standı
4G Mobil Proxy
dedicated server
Sosyal Medya İşleri
Tarayıcı Oyunları
Eticaret Paketleri
Offshore Hosting
güneş paneli
6DD8A
ReplyDeleteTelegram Kanal Satın Al
Düşecek Domainler
adwords kupon satışı
Instagram Takipçi Satın Al
Sosyal Medya Uzmanı
Lisans Satışı
Proxy Satın Al
Vds Satın Al
yabancı dizi önerileri
19258
ReplyDeletecanli goruntulu show
C9464
ReplyDeletewhatsapp güvenilir canlı show
65191
ReplyDeletewhatsapp görüntülü şov
6F915
ReplyDeletegörüntülü şov
3B0C8
ReplyDeletewhatsapp görüntülü show güvenilir