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. Java HttpClient Post请求参数格式为XML

    1.最近忙着做一个接口,拿到文档的时候,what?我当时就震惊了,全都是XML数据传输. 我当时就懵了,哎没得办法,在暑假传输这方面笔者比较熟练json格式数据,简单易懂啊 那就学呗. 2.我在使用的 ...

  2. linux 文件赋权限

    chown tomcat:tomcat /logs chmod 766 /logs

  3. for 和 while 用于遍历时候的区别

    for: 以空格作为间隔符,输出字段. read: 以行作为间隔符,输出字段. 对于文件来说,如果只有一列,for  和  read 无区别, 多列的话, 有区别. read  用法详情: 见 如下转 ...

  4. 在linux服务器以及客户端实现公钥免密登录

    每次登录服务器都要输入密码,这点比较麻烦.使用ssh公钥登录机制可以直接登录,避免每次都输入密码的烦恼. 所谓ssh公钥登录机制即是:客户端电脑client产生加密用的公钥id_rsa.pub与私钥i ...

  5. manjar 搭建aria2c下载器

    从添加或删除软件管理程序里安装 aria2. 在一个地方创建一个文本文件,名为 「aria2.conf」 : rpc-user=我是用户名 rpc-passwd=我是密码 enable-rpc=tru ...

  6. 【ARM-Linux开发】wubi.exe安装Ubuntu14.04出现为/检查磁盘时发生严重错误的解决方法

    原文:http://jingyan.baidu.com/article/0aa22375bbffbe88cc0d6419.html 我写过一篇叫做 如何硬盘装麒麟系统 的经验,介绍了如何不使用优盘的情 ...

  7. 删除Vue中无权限的【node_modules】文件

    npm install rimraf -g rimraf node_modules

  8. [LuoguP1074]靶形数独_搜索

    靶形数独 题目链接:https://www.luogu.org/problem/P1074 数据范围:略. 题解: 传说中的大爆搜题啊. 我觉得这种题就是你能想到什么优化就直接上什么优化.... 这个 ...

  9. 数据库连接池——C3P0&Druid(快速入门)

    数据库连接池--C3P0&Druid (一) 数据库连接池 每一个事物都有其存在的意义,在初学jdbc的时候,我们建立数据库连接对象后,会对其进行释放,但是数据库连接的建立和关闭是非常消耗资源 ...

  10. oracle杀死正在执行的进程

    1 查询目前正在执行的终端和进程, SELECT /*+ rule */ s.username,decode(l.type,'TM','TABLE LOCK','TX','ROW LOCK',NULL ...