Hive 1
参数如下:
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)
hive2 
Beeline和其他工具有一些不同,执行查询都是正常的SQL输入,但是如果是一些管理的命令,
比如进行连接,中断,退出,执行Beeline命令需要带上“!”,不需要终止符。常用命令介绍:
1、!connect url –连接不同的Hive2服务器
2、!exit –退出shell
3、!help –显示全部命令列表
4、!verbose –显示查询追加的明细 The Beeline CLI 支持以下命令行参数,也可以在客户端通过帮助命令查询beeline --help:
Option Description
--autoCommit=[true/false] ---进入一个自动提交模式:beeline --autoCommit=true
--autosave=[true/false] ---进入一个自动保存模式:beeline --autosave=true
--color=[true/false] ---显示用到的颜色:beeline --color=true
--delimiterForDSV= DELIMITER ---分隔值输出格式的分隔符。默认是“|”字符。
--fastConnect=[true/false] ---在连接时,跳过组建表等对象:beeline --fastConnect=false
--force=[true/false] ---是否强制运行脚本:beeline--force=true
--headerInterval=ROWS ---输出的表间隔格式,默认是100: beeline --headerInterval=50
--help ---帮助 beeline --help
--hiveconf property=value ---设置属性值,以防被hive.conf.restricted.list重置:beeline --hiveconf prop1=value1
--hivevar name=value ---设置变量名:beeline --hivevar var1=value1
--incremental=[true/false] ---输出增量
--isolation=LEVEL ---设置事务隔离级别:beeline --isolation=TRANSACTION_SERIALIZABLE
--maxColumnWidth=MAXCOLWIDTH ---设置字符串列的最大宽度:beeline --maxColumnWidth=25
--maxWidth=MAXWIDTH ---设置截断数据的最大宽度:beeline --maxWidth=150
--nullemptystring=[true/false] ---打印空字符串:beeline --nullemptystring=false
--numberFormat=[pattern] ---数字使用DecimalFormat:beeline --numberFormat="#,###,##0.00"
--outputformat=[table/vertical/csv/tsv/dsv/csv2/tsv2] ---输出格式:beeline --outputformat=tsv
--showHeader=[true/false] ---显示查询结果的列名:beeline --showHeader=false
--showNestedErrs=[true/false] ---显示嵌套错误:beeline --showNestedErrs=true
--showWarnings=[true/false] ---显示警告:beeline --showWarnings=true
--silent=[true/false] ---静默方式执行,不显示执行过程信息:beeline --silent=true
--truncateTable=[true/false] ---是否在客户端截断表的列
--verbose=[true/false] ---显示详细错误信息和调试信息:beeline --verbose=true
-d <driver class> ---使用一个驱动类:beeline -d driver_class
-e <query> ---使用一个查询语句:beeline -e "query_string"
-f <file> ---加载一个文件:beeline -f filepath 多个文件用-e file1 -e file2
-n <username> ---加载一个用户名:beeline -n valid_user
-p <password> ---加载一个密码:beeline -p valid_password
-u <database URL> ---加载一个JDBC连接字符串:beeline -u db_URL

beeline常用操作:

1. 将查询结果输出到临时文件中

beeline -u "jdbc:hive2://dwtest-name1:10000/default" -n root --silent=true --outputformat=csv2  -hivevar logdate=${dt}  -f script.q > ${file_tmp}

-f 对应查询的脚本 script.q

--outputformat=csv2 以逗号分隔

--silent=true  静默方式执行,注意:输出文件的时候必须以静默方式运行,否则输出的文本中带有很多程序执行信息。

上述命令执行完成后发现输出的文件中仍然有许多空白行,好像没有参数控制,无奈之下又使用shell命令来过滤空白行。

通过下面任意一行命令来过滤空白行,最后输出结果正常。

#方式一:
#cat ${file_tmp} | sed -e '/^$/d' > ${file} #方式二:
grep -a -v "^$" ${file_tmp} > ${file}

hive & hive beeline常用参数的更多相关文章

  1. Hive记录-Beeline常用操作命令

    Beeline和其他工具有一些不同,执行查询都是正常的SQL输入,但是如果是一些管理的命令, 比如进行连接,中断,退出,执行Beeline命令需要带上"!",不需要终止符.常用命令 ...

  2. hive动态分区常用参数

    set mapreduce.job.queuename=root.sc;set hive.exec.dynamic.partition=true;set hive.exec.dynamic.parti ...

  3. [Hive_add_8] Hive 常用参数配置

    0. 说明 记录 Hive 常用参数的配置 1. 设置本地模式 让 Hive 自动使用 Hadoop 的本地模式运行作业,提升处理性能 适合小文件,一般用于测试 set hive.exec.mode. ...

  4. hive常用参数配置设置

    hive.exec.mode.local.auto 决定 Hive 是否应该自动地根据输入文件大小,在本地运行(在GateWay运行) true hive.exec.mode.local.auto.i ...

  5. Hive入门及常用指令

    基础命令show databases; # 查看某个数据库use 数据库; # 进入某个数据库show tables; # 展示所有表desc 表名; # 显示表结构show partitions 表 ...

  6. [Hive] - Hive参数含义详解

    hive中参数分为三类,第一种system环境变量信息,是系统环境变量信息:第二种是env环境变量信息,是当前用户环境变量信息:第三种是hive参数变量信息,是由hive-site.xml文件定义的以 ...

  7. Hive官方使用手册——新Hive CLI(Beeline CLI)

    Hive官方使用手册——新Hive CLI(Beeline CLI) https://blog.csdn.net/maizi1045/article/details/79481686

  8. 启动hive命令时指定参数或自定义参数

    启动hive命令时指定参数或自定义参数 在hive启动命令中指定一个参数 hive --hiveconf hive.job.submit.username=fuxin.zhao -e "se ...

  9. Linux下查看某个进程打开的文件数-losf工具常用参数介绍

    Linux下查看某个进程打开的文件数-losf工具常用参数介绍 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在linux操作系统中,一切皆文件.通过文件不仅仅可以访问常规数据,还 ...

随机推荐

  1. hduoj----(1033)Edge

    Edge                         Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ( ...

  2. HDUOJ-Counting Triangles

    Counting Triangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  3. SpringBoot定时器

    使用Component注解注解一个类,这个类就变成了一个组件.组件可以有很多不同的特性,比如Scheduled注解为组件的某个函数添加了定时的特性. @Component public class M ...

  4. 使用Block在两个界面之间传值

    首先,创建两个视图控制器,在第一个视图控制器中创建一个UILabel和一个UIButton,其中UILabel是为了显示第二个视图控制器传过来的字符串,UIButton是为了push到第二个界面. 第 ...

  5. ubuntu 安装php-redis

    sudo apt-get install redis-server 测试redis是否安装成功:注意:要开启redisredis-cliset test helloOKget test"ba ...

  6. php 文件上传,下载

    文件下载: html: <html> <body> <a href="1.rar">下载1.rar</a> <br /> ...

  7. RHEL7虚拟机添加新网卡后,网卡无法启动

    RHEL7虚拟机添加新网卡后,网卡无法启动 1.在开启网络时,有错误提示: # systemctl restart network.service Job for network.service fa ...

  8. 于C#控制台传递参数和接收参数

    前言: 写了这么久程序,今天才知道的一个基础知识点,就是程序入口 static void Main(string[] args) 里的args参数是什么意思 ?惭愧... 需求: 点击一个button ...

  9. Spring注解运行时抛出null

    关于Spring的注解其实不难,大致需要以下几个流程: 一.配置Spring的注解支持 <?xml version="1.0" encoding="UTF-8&qu ...

  10. 博客目录之C#

    C# BackgroundWorker的Bug??? C# BeginInvoke和EndInvoke方法 c# 高效的线程安全队列ConcurrentQueue C# ManualResetEven ...