Hive use (reprint)

Import local data imported hive

. Load data local inpath '/root/tes.txt' into table database tables;

Hdfs into the cluster hive

. Load data inpath 'hdfs: // node01: 9000 / user / tes.txt' into table database tables;

HIve partition table (static partitions, dynamic partitioning)

Static partition:

必须在表定义时指定对应的partition字段-----分区字段一定不能与表中字段重复

1. build a single partition table
Here Insert Picture Description

Single-partition table to add data

Here Insert Picture Description

Similar multi-partition:

create table hour(id int, content string) partitioned by (dt int, hour int);

When viewed in hdfs partition is present in the form of a folder. In the form of multi-partition will be similar / dt / hour folders

Increase the number of partitions is

alter table hour add partition(dt=10,hour=40);

Delete partitions is

alter table tablename drop partition (sex=‘boy’)

Dynamic partitioning: automatically after a simple partition data more

Now /conf/hive-site.xml you need to add configuration

Here Insert Picture Description

After configuration is complete

Here Insert Picture Description

Adding data partitions can also be used after the dynamic

from a // table data have already present and
insert overwrite table b partiton (age, sex) overwrite overwrite the data in the table is added into the data
select * distribute by age, sex

Hive sub-barrel table

In the above table have been sub-divided barrel barrels opened up, which can be used directly in

Create a sub-bucket table
Here Insert Picture Description

adding data

insert into table b select id,name from a

According to sub-barrel inside the barrel to find data

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description


Author: Heart 1.5 billion girls
Source: CSDN
Original: https://blog.csdn.net/sksea99/article/details/93121479
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin blog.csdn.net/sincere_love/article/details/93135636