
全不同应用场景吧,HBase
速度比
Hive
快了不知道多少。HBase
对
key
做索引,查询速度非常快(相比较
Hive
),适合实时查询;而Hive是关系型数据结构,适合做后期数据分析。和单机的MySQL,Oracle比较的话,Hive的优点是可以存储海量数据,只是查询速度比较慢。
hive> select
> c1
> ,c2
> ,c3
> ,c4
> from table1
> where dt='2019-02-12' and du ='0'
> limit 5;
OK
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
Time taken: 0113 seconds, Fetched: 5 row(s)
hive> show partitions table1;
OK
dt=2019-02-12/du=0
dt=2019-02-12/du=1
Time taken: 0108 seconds, Fetched: 2 row(s)
--删除分区直接写dt条件即可,下面的du会同时删除
hive> alter table table1 drop partition(dt = '2019-02-12');
Dropped the partition dt=2019-02-12/du=0
Dropped the partition dt=2019-02-12/du=1
OK
Time taken: 0316 seconds
--添加分区时,dt,du需要同时写出来
hive> alter table table1 add partition(dt = '2019-02-12',du='0');
OK
Time taken: 0253 seconds
hive> alter table table1 add partition(dt = '2019-02-12',du='1');
OK
Time taken: 0081 seconds
hive> show partitions table1;
OK
dt=2019-02-12/du=0
dt=2019-02-12/du=1
Time taken: 0075 seconds, Fetched: 2 row(s)
--跑完数据后,刷分区的话,新的字段的数据能查到
hive> select
> c1
> ,c2
> ,c3
> ,c4
> from table1
> where dt='2019-02-12' and du ='0'
> limit 5;
OK
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Time taken: 0092 seconds, Fetched: 5 row(s)
如果目录多,需要执行多条alter语句,非常麻烦。Hive提供了一个"Recover Partition"的功能。
具体语法如下:
MSCK REPAIR TABLE table_name;
原理相当简单,执行后,Hive会检测如果HDFS目录下存在但表的metastore中不存在的partition元信息,更新到metastore中。
end
以上就是关于Hive是什么,Hive与关系型数据库的区别全部的内容,包括:Hive是什么,Hive与关系型数据库的区别、为什么在hive数据库添加分区后在集群的网页里不显示、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)