3.hive常见命令

1 HiveJDBC访问

1.1 启动hiveServer2服务
[code1997@hadoop02 hive]$ bin/hiveserver2
1.2 开启beeline
[code1997@hadoop02 hive]$ bin/beeline

image-20210103221333188

1.3 简单使用

image-20210103221544136

2 Hive常见命令

2.1 常见的交互操作

使用bin/hive -help查看

[code1997@hadoop02 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

[code1997@hadoop02 hive]$ bin/hive -e 'select * from aa;'

image-20210103222632347

2)’-f’执行脚本中sql语句

[code1997@hadoop02 hive]$ touch hive.sql
[code1997@hadoop02 hive]$ vim hive.sql

hive.sql中内容:

select * from aa;

image-20210103223420348

执行文件中的sql语句并将结果写入到文件中:

[code1997@hadoop02 hive]$ bin/hive -f hive.sql >  hive_result.txt

image-20210103223724245

2.2 hive的其他命令操作

1)在 hive cli 命令窗口中如何查看 hdfs 文件系统

hive> dfs -ls /;

image-20210103224445590

2)在 hive cli 命令窗口中如何查看本地文件系统

hive> ! ls /opt/module/data;

image-20210103224215696

3)查看在 hive 中输入的所有历史命令

  • 查看root用户:[root@hadoop02 hive]# cat /root/.hivehistory
  • 查看其他用户:[code1997@hadoop02 hive]$ cat /home/code1997/.hivehistory
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值