通过shell的参数-e可以执行一次就运行完的命令
[root@tianqinglong01 hive]# hive -e "select * from qfdb.t_user" [root@tianqinglong01 hive]# hive --database qfdb -e "select * from t_user"单独执行一个sql文件
[root@tianqinglong01 ~]# vim query.hql select * from t_user; [root@tianqinglong01 ~]# hive -f query.hql执行Linux命令
在Hive的shell中加上前缀!最后以分号;结尾,可以执行linux的命令
hive> !pwd hive> !ls /root执行HDFS命令
用户可以在Hive的shell中执行HDFS的DFS命令,不用敲入前缀hdfs或者hadoop
hive> dfs -ls /显示当前库
下面是通过配置文件hive-site.xml显示
hive.cli.print.current.db true
[root@tianqinglong01 hive]# cd conf/ [root@tianqinglong01 conf]# vim hive-site.xml 添加配置 启动
第二种
[root@tianqinglong01 conf]# vim .hiverc set hive.cli.print.current.db=true 启动local模式
set hive.mode.local.auto=true; (建议打开)



