一、Hive的MapReduce任务
相关配置:
<property>
<name>hive.fetch.task.conversion</name>
<value>more</value>
<description>
Some select queries can be converted to single FETCH task minimizing latency.
Currently the query should be single sourced not having any subquery and should not have
any aggregations or distincts (which incurs RS), lateral views and joins.
1. minimal : SELECT STAR, FILTER on partition columns, LIMIT only //默认
2. more : SELECT, FILTER, LIMIT only (TABLESAMPLE, virtual columns)
</description>
</property>
二、Hive的元数据库的备份与还原
- Hive的元数据存放在mysql的metastore数据库中
- 备份的基本语法:$ mysqldump -uroot -p metastore > metastore.sql
- 还原的基本语法:$ mysql -uroot -p metastore < metastore.sql
三、Hive操作HQL语句的两个参数
- ./hive -e ""; ""里面是Hql语句
- ./hive -f doc.sql
四、Hive历史命令存放地
- cat ~/.hivehistory:主要用于排查逻辑错误或者查看常用命令
五、Hive临时生效设置
- 固定语法:set 属性名=属性值
- 例如:set hive.cli.print.header=false;
六、Hive的内部表与外部表
伪代码:
- hive> CREATE TABLE custom_table(id int, name string) location '/custom/z/hive/somedatabase'
- 默认情况:inner
- hive> CREATE INNER TABLE(报错)
- 显示指定:external
- hive> CREATE EXTERNAL TABLE 2.内部表:删除表数据时,连同数据源以及元数据信息同时删除 3.外部表:
- 只会删除元数据信息。
- 共享数据,外部表相对而言也更加方便和安全。
- 相同之处::如果你导入数据时,操作于HDFS上,则会将数据进行迁移,并在metastore留下记录,而不是copy数据源。