hive的帮助命令:

[hadoop@master tmp]$ hive -help
usage: hive
-d,--define <key=value> Variable substitution to apply to Hive
commands. e.g. -d A=B or --define A=B
--database <databasename> Specify the database to use
-e <quoted-query-string> SQL from command line
-f <filename> SQL from files
-H,--help Print help information
--hiveconf <property=value> Use value for given property
--hivevar <key=value> Variable substitution to apply to Hive
commands. e.g. --hivevar A=B
-i <filename> Initialization SQL file
-S,--silent Silent mode in interactive shell
-v,--verbose Verbose mode (echo executed SQL to the
console)

*hive  -e  --不进入交互式,直接执行

[hadoop@master tmp]$ hive -e "select * from db_hive.u2;"
Logging initialized using configuration in file:/home/hadoop/hive/conf/hive-log4j2.properties Async: true
OK
u2.id   u2.name u2.age  u2.month        u2.day
1       xm1     16      9       14
2       xm2     18      9       14
3       xm3     22      9       14
4       xh4     20      9       14
5       xh5     22      9       14
6       xh6     23      9       14
7       xh7     25      9       14
8       xh8     28      9       14
9       xh9     32      9       14
Time taken: 5.155 seconds, Fetched: 9 row(s

*hive   -f    <filename>
   先准备一个文件:hivef.sql

[hadoop@master tmp]$ more hivef.sql
select * from db_hive.u2;

hive -f hivef.sql

[hadoop@master tmp]$  hive -f hivef.sql

Logging initialized using configuration in file:/home/hadoop/hive/conf/hive-log4j2.properties Async: true
OK
u2.id u2.name u2.age u2.month u2.day
1 xm1 16 9 14
2 xm2 18 9 14
3 xm3 22 9 14
4 xh4 20 9 14
5 xh5 22 9 14
6 xh6 23 9 14
7 xh7 25 9 14
8 xh8 28 9 14
9 xh9 32 9 14
Time taken: 5.398 seconds, Fetched: 9 row(s)

还可以重定向到文件中:

[hadoop@master tmp]$ hive -f hivef.sql>hive_result.txt

Logging initialized using configuration in file:/home/hadoop/hive/conf/hive-log4j2.properties Async: true
OK
Time taken: 5.224 seconds, Fetched: 9 row(s)

查看文件:

[hadoop@master tmp]$ ls -rlt
-rw-rw-r--. 1 hadoop hadoop 26 Apr 2 23:38 hivef.sql
-rw-rw-r--. 1 hadoop hadoop 163 Apr 2 23:49 hive_result.txt
[hadoop@master tmp]$ more hive_result.txt
u2.id u2.name u2.age u2.month u2.day
1 xm1 16 9 14
2 xm2 18 9 14
3 xm3 22 9 14
4 xh4 20 9 14
5 xh5 22 9 14
6 xh6 23 9 14
7 xh7 25 9 14
8 xh8 28 9 14
9 xh9 32 9 14

hive -i <filename>     与用户udf相互使用

hadoop中hive常用的交互式操作的更多相关文章

  1. Hive常用非交互式命令

    [hadoop@hadoop hive-0.13.1]$ bin/hive -help usage: hive -d,--define <key=value> Variable subsi ...

  2. JS中的常用的代码操作

    本文件介绍常用的js代码的DOM操作.CSS操作.对象(Object对象.Array对象.Number对象.String对象.Math对象.JSON对象和Console对象)操作说明. 一.DOM树的 ...

  3. hadoop中hive的属性

    1.在hive中是可以删除文件的: hive> dfs -rm -R /u2.txt > ; Deleted /u2.txt 2.hive 中的default数据库 <propert ...

  4. hive 常用的 join 操作 实例

    test_a 表 id value 1 java 2 python 3 c++ test_b 表 id value 1 java 2 go 3 php 4 c++ 1. join 计算的是笛卡尔积,不 ...

  5. hive常用的字符串操作函数

  6. hive 常用操作

    参考:https://www.cnblogs.com/jonban/p/10779938.html Hive 启动:hive 退出:hive>quit; show databases; use  ...

  7. 入门大数据---Hive常用DML操作

    Hive 常用DML操作 一.加载文件数据到表 1.1 语法 LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename ...

  8. hadoop入门到实战(6)hive常用优化方法总结

    问题导读:1.如何理解列裁剪和分区裁剪?2.sort by代替order by优势在哪里?3.如何调整group by配置?4.如何优化SQL处理join数据倾斜?Hive作为大数据领域常用的数据仓库 ...

  9. Hive常用的SQL命令操作

    Hive提供了很多的函数,可以在命令行下show functions罗列所有的函数,你会发现这些函数名与mysql的很相近,绝大多数相同的,可通过describe function functionN ...

随机推荐

  1. 海康大华RTSP格式

    海康实时流:rtsp://admin:12345@192.2.82.50:554/h264/ch4/main/av_stream海康回放流(模拟通道):rtsp://admin:12345@192.2 ...

  2. MATLAB常用快捷键总结

    MATLAB 命令栏显示处理的常用命令 清屏:clc 紧凑显示格式:format compact 宽松显示格式:format loose 数据高精度显示:format longG 数据低精度显示:fo ...

  3. PAT 甲级 1022 Digital Library (30 分)(字符串读入getline,istringstream,测试点2时间坑点)

    1022 Digital Library (30 分)   A Digital Library contains millions of books, stored according to thei ...

  4. 深入理解Attention机制

    要了解深度学习中的注意力模型,就不得不先谈Encoder-Decoder框架,因为目前大多数注意力模型附着在Encoder-Decoder框架下,当然,其实注意力模型可以看作一种通用的思想,本身并不依 ...

  5. OPC 数据交互环境配置

    本文源自ioufev先生的博客<OPC和DCOM配置>(https://www.cnblogs.com/ioufev/p/9365919.html)及「geekc」先生的<OPC工作 ...

  6. java 分布式实践

    java 分布式实践 spring boot cloud实践 开源的全链路跟踪很多,比如 Spring Cloud Sleuth + Zipkin,国内有美团的 CAT 等等. 其目的就是当一个请求经 ...

  7. sws office-强大小巧的开源office

    sws office是一款由国际软件分享组织于2019年刚刚开发完成的一个开源office,目的是为了响应CR2019的号召,开发一个体积只有2.2MB,占用内存小,运行速度极快的office,它支持 ...

  8. iostream

    cout 星号*为默认 控制符 描 述 控制符 描 述 *dec 以十进制形式输出整数 hex 以十六进制形式输出整数 oct 以八进制形式输出整数 fixed 以普通小数形式输出浮点数 scient ...

  9. .Net WebApi接口之Swagger集成详解

    本文详细的介绍了.net从一个新的项目中创建api后集成swagger调试接口的流程! 1.首先我们创建一个MVC项目(VS2012): 2.然后在项目中的Controllers文件夹中添加API接口 ...

  10. 《鸟哥的Linux私房菜:基础学习篇》读书笔记之第一部分

    一.如何学习Linux 1. Linux基础知识 (1) 计算机概论与硬件相关知识. (2) 先从Linux的安装与命令学起. (3) Linux操作系统的基础技能.如用户/用户组.权限.程序等概念. ...