LoginSignup
3
4

More than 5 years have passed since last update.

HIVEコマンドでのDatabase選択について

Last updated at Posted at 2014-09-02

コマンドラインからHIVEコマンド経由でHQLを叩く方法として、

hive -e "SELECT * FROM hoge_table;"

と書けます。
しかし、この書き方では、hoge_tableのデータベースがdefaultにある場合のみ実行できます。

データベースを指定して書く場合には、一行の中で

hive -e "USE foo_db; SELECT * FROM hoge_table;"

とすると、foo_dbのhoge_tableが選択されることになります。
もちろん、foo_dbのhoge_tableがなければいけません。

fileの中にHQLを書いた場合の実行は、

hive -f /path/to/hivescript.hql

と書くことができます。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4