学习hive知识点

1、创建视图:
hive> CREATE VIEW valid_records AS SELECT * FROM records2 WHERE temperature !=9999;

2、查看视图详细信息:
hive> DESCRIBE EXTENDED valid_records;

3、从表中导出数据:
hadoop fs -cp source_path target_path
或者:用户可以使用 insert……directory……
insert overwrite local directory '/tmp/目录' 这里指定的路径也可以是全URL路径

4、hive中使用正则表达式
(1) hive> select 'price.*' from table_name;
选出所有列名以price作为前缀的列
(2) 用Like或者RLike

5、聚合函数
可以通过设置属性hive.map.aggr值为true来提高聚合的性能:
hive>hive.map.aggr=true;

6、什么情况下hive可以避免进行mapreduce?
在本地模式的时候可以避免触发一个mr的job,此外,如果属性hive.execmode.local.auto的值为true的话,hive还户尝试本地模式进行其他的操作。
set hive.execmode.local.auto=true;
说明:最好将 set hive.execmode.local.auto=true;这个设置增加到你的$HOME/.hiverc配置文件中去。

7、JOIN语句
hive支持通常的SQL JOIN语句,但是只支持等值连接。hive也不支持在on子句中用谓词OR

8、union all
将两个表或者多个表进行合并,每一个union all子查询都必须具有相同的列,而且对应每个字段的每个类型都必须一致。

posted @ 2021-09-25 12:21  yasai  阅读(97)  评论(0编辑  收藏  举报