hive中的分区表的基本操作

有些话、适合烂在心里 提交于 2019-12-02 05:19:16

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的差不多,这里不在给出
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!