描述: 原先數據是存儲在hbase中的,但是直接查詢hbase速度慢(hbase是寬表結構),所以想把數據遷移到hive中;
1.先hbase 和 hive創建 外部表鏈接, 可以在hive直接查詢;
2.利用創建的外部表,直接在hive中創建內部表;
直接上代碼:
#創建hive外部表鏈接
CREATE EXTERNAL TABLE hbase_table_hive3( key string, 字段名稱 double ) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,data:字段名稱") TBLPROPERTIES("hbase.table.name" = "table_name"); #創建hive內部表 create table table_name as select * from hbase_table_hive3;
#刪除中間表 drop table hbase_table_hive3;