hive中的分区表的基本操作
#查询某个表下有哪些分区 dept_partition是表名
hive (default)> show partitions dept_partition;
OK
month=20190922
month=20190923
month=20190924
1.查询分区表中数据
- 单分区查询
hive (default)> select * from dept_partition where month=‘20190922’;
- 多分区查询
hive (default)> select * from dept_partition where month='20190923'
union
select * from dept_partition where month='20190924';
2.创建分区
- 创建单个分区
hive (default)> alter table dept_partition add partition(month=‘20190925’);
#查询某个表下有哪些分区 dept_partition是表名
hive (default)> show partitions dept_partition;
OK
month=20190922
month=20190923
month=20190924
month=20190925
- 创建多个分区
hive (default)> alter table dept_partition add partition(month=‘20190926’)partition(month=‘20190927’);
#查询某个表下有哪些分区 dept_partition是表名
hive (default)> show partitions dept_partition;
OK
month=20190922
month=20190923
month=20190924
month=20190925
month=20190926
month=20190927
3. 重命名表
#dept_partition2 旧表名 dept_partition4是新表名
hive (default)> alter table dept_partition2 rename to dept_partition4;
4. 查询有哪些表
hive (default)> show tables;
5. 查询某个表下有哪些分区 dept_partition是表名
hive (default)> hive (default)> show partitions dept_partition;
6. 查询某个表的详细信息
hive (default)> desc formatted dept_partition;
7. 查询某个表的粗略信息
hive (default)> desc dept_partition;
8. 表的增删改查mysql的差不多,这里不在给出
来源:CSDN
作者:星光不负赶路人~
链接:https://blog.csdn.net/qq_43192537/article/details/101176571