05 Hive查詢Hbase中的資料

2021-10-04 02:11:10 字數 1063 閱讀 3673

這一節我們將介紹hive查詢hbase中資料的過程。

export hadoop_home=/root/hadoop-2.5.2

export hbase_home=/root/hbase-1.2.6

cd /root/hbase-1.2.6/bin

./hbase shell

# 注意,「hbase(main):006:0> 」是命令列字首,t8是表名,f8是列簇名

hbase(main):006:0> create 't8','f8'

hbase(main):006:0> put 't8','key1','f8:id','1'

hbase(main):006:0> put 't8','key1','f8:name','ali'

hbase(main):006:0> put 't8','key2','f8:id','1'

hbase(main):006:0> put 't8','key2','f8:name','xiaoli'

hbase(main):006:0> put 't8','key3','f8:id','1'

hbase(main):006:0> put 't8','key3','f8:name','zhangli'

# 進入hive安裝目錄

cd /root/apache-hive-0.14.0-bin/bin

./hive

# 執行以下命令建立外部表,注意,「hive>」是命令列字首

hive> create external table t8(key string,id int,name string) stored by

'org.apache.hadoop.hive.hbase.hbasestoragehandler' with serdeproperties

tblproperties("hbase.table.name" = "t8");

# 查詢t8表

hive> select * from t8;

以上就是在hive中查詢hbase中資料的過程。

Hive 05 資料查詢

select from table name select sid,sname from table name select sid sname sal sal 12from table name select sid sname sal comm,sal 12 nvl comm,0 from ta...

hbase資料遷移到hive中

描述 原先資料是儲存在hbase中的,但是直接查詢hbase速度慢 hbase是寬表結構 所以想把資料遷移到hive中 1.先hbase 和 hive建立 外部表鏈結,可以在hive直接查詢 2.利用建立的外部表,直接在hive中建立內部表 直接上 建立hive外部表鏈結 create extern...

Hive和HBase的區別

hive是為了簡化編寫mapreduce程式而生的,使用mapreduce做過資料分析的人都知道,很多分析程式除業務邏輯不同外,程式流程基本一樣。在這種情況下,就需要hive這樣的使用者程式設計介面。hive本身不儲存和計算資料,它完全依賴於hdfs和mapreduce,hive中的表純邏輯,就是些...