hive的帮助命令:

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

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

  1. [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

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

hive -f hivef.sql

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

还可以重定向到文件中:

  1. [hadoop@master tmp]$ hive -f hivef.sql>hive_result.txt
  2.  
  3. Logging initialized using configuration in file:/home/hadoop/hive/conf/hive-log4j2.properties Async: true
  4. OK
  5. Time taken: 5.224 seconds, Fetched: 9 row(s)

查看文件:

  1. [hadoop@master tmp]$ ls -rlt
  2. -rw-rw-r--. 1 hadoop hadoop 26 Apr 2 23:38 hivef.sql
  3. -rw-rw-r--. 1 hadoop hadoop 163 Apr 2 23:49 hive_result.txt
  4. [hadoop@master tmp]$ more hive_result.txt
  5. u2.id u2.name u2.age u2.month u2.day
  6. 1 xm1 16 9 14
  7. 2 xm2 18 9 14
  8. 3 xm3 22 9 14
  9. 4 xh4 20 9 14
  10. 5 xh5 22 9 14
  11. 6 xh6 23 9 14
  12. 7 xh7 25 9 14
  13. 8 xh8 28 9 14
  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. mac 终端杀进程

    killall 进程名 killall chromedriver 查看进程名的·方法:

  2. JAVA 基础编程练习题25 【程序 25 求回文数】

    25 [程序 25 求回文数] 题目:一个 5 位数,判断它是不是回文数.即 12321 是回文数,个位与万位相同,十位与千位相同. package cskaoyan; public class cs ...

  3. Spark源码资料汇总

    近几月,想要了解Spark的内部实现原理,因此想要查阅Spark的源码信息,现将所了解的资料汇总如下: 1. 博客文字类 (1) 官网 1) github 2) Spark官网 (2) gitbook ...

  4. 12-1 TCP/IP协议栈

    TCP/IP协议栈 有限状态机FSM:Finite State Machine CLOSED 没有任何连接状态 LISTEN 侦听状态,等待来自远方TCP端口的连接请求 SYN-SENT 在发送连接请 ...

  5. centos安装软件

    rpm指令, 该指令安装文件后缀.rpm的可执行程序 yum指令 安装软件源代码,后缀为 .tar.gz(用gzip压缩过的tar包) rpm rpm软件包格式为 (一)查询系统装已经安装的软件信息 ...

  6. from提交数据,高级选择器,伪类选择器,前端样式等

    1. form提交数据 get: 不安全的提交数据,高效 post: 安全的提交数据,低效 前台都可以给后台提交数据,后台一定会给前台一个反馈结果 2. 高级选择器 <!DOCTYPE html ...

  7. Linux上,最常用的一批命令解析(10年精选)

    Linux这么多命令,通常会让初学者望而生畏.下面是我结合日常工作,以及在公司的内部培训中,针对对Linux不是很熟悉的同学,精选的一批必须要搞懂的命令集合.任何一个命令其实都是可以深入的,比如tai ...

  8. NOIP 2015:信息传递

    题目描述 有n个同学(编号为1到n)正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为i的同学的信息传递对象是编号为Ti同学. 游戏开始时,每人都只知道自己的生日.之后每一 ...

  9. python xlrd模块

    一.什么是xlrd模块? Python操作excel主要用到xlrd和xlwt这两个库,即xlrd是读excel,xlwt是写excel的库. 二.使用介绍 1.常用单元格中的数据类型 类型 含义 e ...

  10. 【转贴】linux 终端报Message from syslogd

    linux 终端报Message from syslogd xiao9873341760人评论8537人阅读2017-03-27 14:19:31 https://blog.51cto.com/xia ...