How to write a script file in Hive?

2019-07-09 00:36发布

问题:

I am a newbie to Hive and trying to write a script file which contains 3 queries in it.I have already created the table in /user/hive/warehouse(default database).I am not sure where to save the script file and what command to use to execute it?Looking forward for a solution. Info:I am working on hive-ubuntu. Thanks Sweesha

回答1:

in local FS :

/home/username/some/path/Query1.q (.hql) -- inside it query is "show databases;"

(give all three Queries in one file if needed)

from shell $:

user@hostname $ $HIVE_HOME/bin/hive -f /home/username/some/path/Query1.q
OK
database_name
db
default
financials
mydb

from hive CLi :

hive> source /home/username/some/path/Query1.q



标签: hive