Hive學習筆記四 -- Hive交互方式

1、shell方式

  進入hive的shell界面,直接輸入HiveQL語句,就可以操作Hive數據庫了,這種方式的優點是簡單明瞭。

進入hive的shell界面:
/export/servers/apache-hive-3.1.0-bin/bin/hive

輸入HiveQL語句:
在這裏插入圖片描述

2、腳本方式

2.1、hive -e

使用hive -e命令,執行單句HiveQL語句

cd /export/servers/apache-hive-3.1.0-bin
bin/hive -e “create database if not exists mytest;”

2.2、hive -f

使用hive -f命令,可以執行SQL腳本,這樣的優點是可以做一下批量處理或者定時服務。

cd /export/servers
vim hive.sql


> create database if not exists mytest; 
> use mytest; 
> create table stu(id int,name string);

通過hive -f 來執行我們的sql腳本

hive -f /export/servers/hive.sql

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章