您好,登錄后才能下訂單哦!
這篇文章主要講解了“Hive的基本使用”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Hive的基本使用”吧!
Hive有三種復(fù)雜數(shù)據(jù)類型ARRAY、MAP 和 STRUCT。ARRAY和MAP與Java中的Array和Map類似,而STRUCT與C語言中的Struct類似,它封裝了一個命名字段集合,復(fù)雜數(shù)據(jù)類型允許任意層次的嵌套。
創(chuàng)建數(shù)據(jù)表
create table test(name string,friends array<string>,children map<string, int>,address struct<street:string, city:string>)row format delimited fields terminated by ','collection items terminated by '_'map keys terminated by ':'lines terminated by '\n';
查看數(shù)據(jù)結(jié)構(gòu)
hive (default)> desc test;OKcol_name data_type commentname string friends array<string> children map<string,int> address struct<street:string,city:string> Time taken: 0.053 seconds, Fetched: 4 row(s)
測試數(shù)據(jù)
liming,zhangsan_lisi,xiao ming:12_xiaoxiao ming:3,haidian_beijingwangwu,zhaoliu_sunba_qianer,xiao wang:18_xiaoxiao wang:9,chao yang_beijing
加載測試數(shù)據(jù)
hive (default)> load data local inpath '/opt/module/data/people.txt' into table test;Loading data to table default.testTable default.test stats: [numFiles=1, numRows=0, totalSize=141, rawDataSize=0]OKTime taken: 0.354 seconds
查看數(shù)據(jù)內(nèi)容
hive (default)> select *from test;OKtest.name test.friends test.children test.addressliming ["zhangsan","lisi"] {"xiao ming":12,"xiaoxiao ming":3} {"street":"haidian","city":"beijing"}wangwu ["zhaoliu","sunba","qianer"] {"xiao wang":18,"xiaoxiao wang":9} {"street":"chao yang","city":"beijing"}Time taken: 0.069 seconds, Fetched: 2 row(s)
##Mysql 查看hive表結(jié)構(gòu)
查看表的字段
##加載數(shù)據(jù)到hive中
LOAD DATA LOCAL(本地文件需要添加LOCAL) INPATH '文件路徑' OVERWRITE INTO TABLE 表名稱;
感謝各位的閱讀,以上就是“Hive的基本使用”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Hive的基本使用這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。