hive基础知识

hive内部表和外部表的区别
内部表:创建表时,默认创建的就是内部表,删除时会删除元数据(数据库中tabs中的表数据)和数据内容(hdfs dfs -ls /user/hive/warehouse/数据库名.db/表名),都会删除掉,所以内部表多用于临时表和中间表
外部表:创建时需要一个关键字external,删除时,只删除元数据,不删除数据内容,所以多用于数据源。

hive查询:union all 和union的区别
union:查询结果及合并,并且去除重复行:
union all:查询结果集合并,不删除重复行;

hive:分区关键字partitioned 并且分区字段可以不用真正的字段,查询的时候却可以用这个字段查询,比如where year=2018
create table if not exists student(
id bigint comment ‘studentId’,
name String
)
partitioned by(year String)
row format delimited fields terminated by ‘\t’

分区加载数据时:
load data local inpath ‘/home/data/student’ into table student partition(year=’2018’);

显示分区:
show partitions student ;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值