hadoop中hive常用的交互式操作
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常用的交互式操作的更多相关文章
- Hive常用非交互式命令
[hadoop@hadoop hive-0.13.1]$ bin/hive -help usage: hive -d,--define <key=value> Variable subsi ...
- JS中的常用的代码操作
本文件介绍常用的js代码的DOM操作.CSS操作.对象(Object对象.Array对象.Number对象.String对象.Math对象.JSON对象和Console对象)操作说明. 一.DOM树的 ...
- hadoop中hive的属性
1.在hive中是可以删除文件的: hive> dfs -rm -R /u2.txt > ; Deleted /u2.txt 2.hive 中的default数据库 <propert ...
- 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 计算的是笛卡尔积,不 ...
- hive常用的字符串操作函数
- hive 常用操作
参考:https://www.cnblogs.com/jonban/p/10779938.html Hive 启动:hive 退出:hive>quit; show databases; use ...
- 入门大数据---Hive常用DML操作
Hive 常用DML操作 一.加载文件数据到表 1.1 语法 LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename ...
- hadoop入门到实战(6)hive常用优化方法总结
问题导读:1.如何理解列裁剪和分区裁剪?2.sort by代替order by优势在哪里?3.如何调整group by配置?4.如何优化SQL处理join数据倾斜?Hive作为大数据领域常用的数据仓库 ...
- Hive常用的SQL命令操作
Hive提供了很多的函数,可以在命令行下show functions罗列所有的函数,你会发现这些函数名与mysql的很相近,绝大多数相同的,可通过describe function functionN ...
随机推荐
- kvm管理工具Webvirtmgr安装
虚拟机版本vmware workstation 15.5.0 pro (也就是linux版) cat /etc/redhat-release CentOS Linux release 7.4.17 ...
- [dart学习]第六篇:流程控制语句
经过前面的基础知识了解学习,我们今天可以进入语句模块啦. dart主要有以下流程控制语句: if-else for循环 while和do-while循环 break和continue switch-c ...
- CockroachDB学习笔记——对此的选择
无意间了解到TiDB,然后知道了他是一款国产团队开源的NewSQL数据库, 看了一下官网,有很多中文的文档和技术分享挺不错的. 但是安装起来好像挺麻烦的说. 测试的硬件环境 也吓死我了,我只有一台笔记 ...
- ubuntu 18.04安装ftp服务器
首先安装vsftpd: sudo apt-get install vsftpd 可以通过命令vsftpd -version查看vsftpd版本. 为ftp服务器新建一个用户(比如我这里新建一个用户名和 ...
- iOS-SVPullToRefresh下拉刷新,上拉加载(转)
https://github.com/Sephiroth87/ODRefreshControl 类似刷新控件,类似qq动画的那种刷新. 一.下载第三方库 https://github.com/samv ...
- WordPress自定义菜单和修改去除多余的css
这里主要是用于模板制作的,一般前端已经写好了,我们只要将前端的内容套用WordPress后台就可以了. 所以我们在模板制作过程中,需要自定义WordPress菜单. 在functions.php文件中 ...
- linux查看端口进程占用情况
本文介绍linux如何查看端口被哪个进程占用的方法: 1.lsof -i:端口号 2.netstat -tunlp|grep 端口号 都可以查看指定端口被哪个进程占用的情况 [步骤一]lsof -i ...
- selenium3关于ddt驱动之读取json文件。。。
from selenium import webdriver import ddt import time import unittest """ DDT(驱动.json ...
- 最新 美图java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.美图等10家互联网公司的校招Offer,因为某些自身原因最终选择了美图.6.7月主要是做系统复习.项目复盘.LeetCode ...
- 第07组 Alpha冲刺(1/4)
队名:秃头小队 组长博客 作业博客 组长徐俊杰 过去两天完成的任务:完成人员分配,初步学习Android开发 Github签入记录 接下来的计划:继续完成Android开发的学习,带领团队进行前后端开 ...