本文所需环境如下:
操作系统:CentOS 7.2 64位
Hive版本:2.1.1
JDK版本:jdk1.8.0_131
Hadoop版本:2.8.1
IDE: IntelliJ IDEA 2017.2.2
创建分区表book
创建分区表book
hive> create table book (id int, name string) partitioned
by (category string ) row format delimited fields terminated by ' ';
加载中文书和英文书
加载中文书和英文书
hive> load data local inpath '/root/englishBook.txt' overwrite into
table book partition (category='en');
hdfs下多了两个目录
查看hdfs数据
查看book表中的数据
book表中的数据
手工加入一个jp分区
手工加入一个jp分区
hive的元数据并没有更新,所以不认识这个分区
hive的元数据并没有更新
更新hive元数据
更新hive元数据
hive> msck repair table book;
查看book表的分区
查看book表的分区
hive> show partitions book;
删除分区
删除分区
hive> alter table book drop partition(category='jp');
更改分区名
更改分区名
hive> alter table book partition(category='cn') rename to partition (category='chinese');
hdfs中的目录变化
hdfs中的目录变化
mysql中的分区信息
mysql中的分区信息
mysql> select * from SDS;