日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hive视图

發布時間:2025/3/11 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hive视图 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


數據

數據文件v_t1

[root@hello110 data]# vi v_t1
lisi ? ?22 ? ? ?100000
ximing ?22 ? ? ?100022
xiaoji ?23 ? ? ?100033
xiaohua 24 ? ? ?100044
xx ? ? ?22 ? ? ?100055


數據文件v_t2

[root@hello110 data]# vi v_t2
lisi ? ?23 ? ? ?100000
ximing ?22 ? ? ?100022
xiaoji ?23 ? ? ?100033
xiaohua 24 ? ? ?100044
xx1 ? ? 22 ? ? ?100055
xx2 ? ? 22 ? ? ?100066
xx3 ? ? 22 ? ? ?100077


創建測試表v_t1

hive (zmgdb)> create table v_t1(name string,age int,slary int)
? ? ? ? ? ? > row format delimited fields terminated by '\t';


創建測試表v_t2

hive (zmgdb)> create table v_t2(name string,age int,slary int)
? ? ? ? ? ? > row format delimited fields terminated by '\t';??


導入數據

hive (zmgdb)> load data local inpath '/data/v_t1' into table v_t1;
Loading data to table zmgdb.v_t1
OK

hive (zmgdb)> load data local inpath '/data/v_t2' into table v_t2;
Loading data to table zmgdb.v_t2
OK


創建視圖

hive (zmgdb)> create view view_t1t2?
? ? ? ? ? ? > as
? ? ? ? ? ? > select t1.age,t1.name as t1name,t1.slary as t1slary,t2.name as t2name,t2.slary as t2slary?

?? ? ? >?from v_t1 t1,v_t2 t2
? ? ? ? ? ? > where t1.age=t2.age;
OK
age ? ? t1name ?t1slary t2name ?t2slary
Time taken: 0.141 seconds

PS:視圖的字段名不能重復。如果相同會報?FAILED: SemanticException [Error 10036]: Duplicate column name:



查詢視圖

hive (zmgdb)> select * from view_t1t2;

hive會啟動MapReduce


hive (zmgdb)> show tables;
OK
tab_name
bucket_t1
bucket_t2
bucket_t3
p_t1
p_t3
p_t4
t1
t2
v_t1
v_t2

view_t1t2


刪除視圖

drop view if exists v1;


補充

view只存在hive的metastore 中,不存在hadoop中。


總結

以上是生活随笔為你收集整理的hive视图的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。