1 建立表 hive命令列操作
create table if not exists emp(2 造資料name string,
salary float,
subordinates array,
deductions map,
address struct)
partitioned by (province string,city string)
row format delimited
fields terminated by '\t'
collection items terminated by ','
map keys terminated by ':』;
shanxi.txt
zj1 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,xian,shanxi,1hunan.txtzj2 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,xian,shanxi,2
zj3 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,xian,shanxi,3
zj4 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,xian,shanxi,4
zj5 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,xian,shanxi,5
zj6 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,xian,shanxi,6
zbq1 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,zhangjiajie,hunan,13 匯入資料 hive命令列操作zbq2 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,zhangjiajie,hunan,2
zbq3 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,zhangjiajie,hunan,3
zbq4 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,zhangjiajie,hunan,4
zbq5 10000 james,datacloase jim:1.2,james:2.1,lilly:3.8 huaxing,zhangjiajie,hunan,5
load data local inpath '/tmp/logs/shanxi.txt' overwrite into table emp4 查詢hive資料partition(province='shanxi',city='xian』);
load data local inpath '/tmp/logs/hunan.txt' overwrite into table emp
partition(province='hunan',city='zhangjiajie』);
hive表結構
查詢hive分割槽資料
5 檢視hdfs的hive目錄
6 刪除hive中hunan的分割槽
a 進入hive使用的mysql
b 切換為hive資料庫
mysql> use hive;
c 查詢相關表
發現出現1條記錄,所以使用tbls表的sd_id欄位去sds表查詢location欄位的值,通過location欄位,就可以知道emp這張表的資料庫,tbls中tbl_id為6的這行記錄就是我要查詢的表的id
接下來,要根據tbls表的tbl_id和hive表分割槽欄位的值(模糊查詢)去partitions表查詢,需要得到partitions表的part_id的值(2)
d開始刪除
最後,通過tbls表的tbl_id(70)和partitions表的part_id(202354)就可以刪除hive的分割槽了
mysql> mysql> delete from partition_key_vals where part;
query ok, 0 rows affected (0.00 sec)
mysql> delete from partition_key_vals where part_id=2;
query ok, 2 rows affected (0.00 sec)
mysql> delete from partition_params where part_id=2;
query ok, 6 rows affected (0.01 sec)
mysql> delete from partitions where tbl_id=6 and part_id=2;
query ok, 1 row affected (0.00 sec)
刪除hdfs相關分割槽目錄
[root@hdp1 /root]#hdfs dfs -rm -r "/user/hive/warehouse/emp/province=hunan"
deleted /user/hive/warehouse/emp/province=hunan
7 查詢分割槽是否刪除
已經查詢不出來hunan的分割槽資料了
hive> select * from emp where province='hunan';
oktime taken: 0.073 seconds
hive 自定義元資料表 Hive 元資料表含義
hive 元資料表含義 1 version 查詢版本資訊 fieldtypecomment ver id bigint 20 id主鍵 schema version varchar 127 hive版本 version comment varchar 255 版本說明 2 dbs 儲存hive中所有...
hive中的元資料表資訊以及表關係
字段 描述ver id 主鍵schema version 版本version comment 說明字段 描述db id 庫iddesc 庫描述db location uri hdfs上的路徑 name 資料庫名稱 owner name 所有著使用者名稱 owner type 所有者角色 字段描述 t...
表元資料統計 統計MySQL資料表大小
需要統計表的元資料基本資訊 如統計表的容量大小 行數等,可引數如下語句 select table name,data length 1024 1024 as datam index length 1024 1024 as indexm,data length index length 1024 10...