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. [ML] Linear Discriminant Analysis

    虽然名字里有discriminat这个字,但却是生成模型,有点意思. 判别式 pk 生成式 阅读:生成方法 vs 判别方法 + 生成模型 vs 判别模型 举例: 判别式模型举例:要确定一个羊是山羊还是 ...

  2. Java NIO 学习笔记 读写结合补充

    小练习:nio读写文件,将fileread中的内容读取到filewrite中 try { //创建输入通道 FileInputStream fis = new FileInputStream(&quo ...

  3. 本地文件上传到Linux服务器

    1.从服务器上下载文件scp username@servername:/path/filename /var/www/local_dir(本地目录) 例如scp root@192.168.0.101: ...

  4. css解决fixed布局不会出现滚动条的问题

  5. iOS- 推送消息

    1 ios 如何判断是点击推送信息进入还是点击app图标进入程序? 设备接到apns发来的通知,应用处理通知有以下几种情况: 1. 应用还没有加载 这时如果点击通知的显示按钮,会调用didFinish ...

  6. JavaScript基础------JavaScript语法

    js的注释与分号 // 单行注释 /**/多行注释 ctrl +shift +/ 语句结束使用分号,如果省略,则由解析器确定语句的结尾js语法 1.变量.函数名.操作符都区分大小写 2.标识符 (1) ...

  7. 如何解决docker 官方镜像拉取慢的问题

    转自: http://skycity.today/?thread-307.htm 国内从 docker 官方 Registry 拉取 image 慢的解决,步骤如下: 1.注册一个阿里云账号. 2.阿 ...

  8. SSH命令工具研究报告

    0 什么是SSH Secure Shell(安全外壳协议,简称SSH)是一种加密的网络传输协议,可在不安全的网络中为网络服务提供安全的传输环境.SSH通过在网络中创建安全隧道来实现SSH客户端与服务器 ...

  9. redis-5.0.3 redis.conf详解

    # Redis configuration file example. # # Note that in order to read the configuration file, Redis mus ...

  10. 01.04 linux命令(2

    ======================Linux下的用户管理==============用户信息保存/etc/passwd ,一般用户都有读的权限真正的用户:修改密码,可以登录伪用户:应用程序在 ...