1.2 Hive常见命令

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

[root@hadoop102 hive]# bin/hive -e "select id from student;"

2.“-f”执行脚本中sql语句
(1)在/opt/module/datas目录下创建hivef.sql文件

[root@hadoop102 datas]# touch hivef.sql

文件中写入正确的sql语句

select *from student;

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

[root@hadoop102 hive]# bin/hive -f /opt/module/datas/hivef.sql

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

[root@hadoop102 hive]# bin/hive -f /opt/module/datas/hivef.sql  > /opt/module/datas/hive_result.txt

3.退出hive窗口:

hive(default)>exit;
hive(default)>quit;

在新版的hive中没区别了,在以前的版本是有的:
exit:先隐性提交数据,再退出;
quit:不提交数据,退出;
4.在hive cli命令窗口中如何查看hdfs文件系统

hive(default)>dfs -ls /;

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

hive(default)>! ls /opt/module/datas;

6.查看在hive中输入的所有历史命令
(1)进入到当前用户的根目录/root或/home/atguigu
(2)查看. hivehistory文件

[root@hadoop102 ~]# cat .hivehistory
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值