大数据之hive:常用交互命令及其他操作命令

一、常用交互命令:
1.“-e”不进入hive的交互窗口执行sql语句

[hadoop@bigdata02 hive]$ bin/hive -e "select id from student;"

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

[hadoop@bigdata02 datas]$ touch hivef.sql

文件中写入正确的sql语句
select *from student;
(2)执行文件中的sql语句

[hadoop@bigdata02 hive]$ bin/hive -f /opt/module/datas/hivef.sql

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

[hadoop@bigdata02 hive]$ bin/hive -f /opt/module/datas/hivef.sql  > /opt/module/datas/hive_result.txt

二、其他命令操作
1.退出hive窗口:

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

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

hive(default)>dfs -ls /;

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

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

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

[hadoop@bigdata02 ~]$ cat .hivehistory

猜你喜欢

转载自blog.csdn.net/weixin_43597208/article/details/112341528