hive中的2级分区表的创建

hive中的2级分区表的创建

解释:就是多级文件夹

1.创建二级分区表

hive (default)> create table dept_partition2(
deptno int, dname string, loc string
)
partitioned by (month string, day string)
row format delimited fields terminated by ‘\t’;

dept.txt文件的创建方法链接

2.加载数据到分区表中

hive (default)>hive (default)> load data local inpath ‘/opt/moudles/cdh/hive-0.13.1-cdh5.3.6/input/dept.txt’ into table dept_partition2 partition (month=‘20190928’,day=‘01’);

3.命令查看 (详细信息)
/user/hive/warehouse是我配置的hive仓库目录

hive (default)> dfs -ls /user/hive/warehouse/dept_partition2/month=20190928;


Found 2 items
drwxr-xr-x   - admin supergroup          0 2019-09-23 08:51 /user/hive/warehouse/dept_partition2/month=20190928/day=01
drwxr-xr-x   - admin supergroup          0 2019-09-23 08:50 /user/hive/warehouse/dept_partition2/month=20190928/day=02

3.命令查看 (粗略信息)

hive (default)> hive (default)> show partitions dept_partition2;


OK
month=20190928/day=01
month=20190928/day=02
Time taken: 0.038 seconds, Fetched: 2 row(s)

4. 查询分区数据

hive (default)> select * from dept_partition2 where month=20190928 and day=01;

你可能感兴趣的:(hive)