黑猴子的家:Hive 常用交互命令

[victor@node1 hive]$ bin/hive –help

usage: hive
 -d,--define <key=value>          Variable subsitution 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 subsitution 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)

1、“-e”不进入hive的交互窗口执行sql语句

[victor@node1 hive]$ bin/hive -e "select id from student;"

2、“-f” 执行脚本中sql语句

(1)在/opt/module/datas目录下创建hivef.sql文件

[victor@node1 datas]$ touch hivef.sql
[victor@node1 datas]$ vim hivef.sql
select * from student;

(2)执行文件中的sql语句

[victor@node1 hive]$ bin/hive -f /opt/module/datas/hivef.sql

3、执行文件中的sql语句并将结果写入文件中

[victor@node1 hive]$ bin/hive -f  \
/opt/module/datas/hivef.sql > /opt/module/datas/hive_result.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值