shell中执行hive语句
1.执行select查询
$HIVE_HOME/bin/hive -e 'select a.col from tab1 a'
$HIVE_HOME/bin/hive -e "use mydb;select a.col from tab1 a where a.dt='2015-01-07';"
2.加入配置变量的查询
$HIVE_HOME/bin/hive -e 'select a.col from tab1 a' -hiveconf hive.exec.scratchdir=/home/my/hive_scratch -hiveconf mapred.reduce.tasks=32
3.查询结果输出为文本
$HIVE_HOME/bin/hive -S -e 'select a.col from tab1 a' > a.txt
4.执行sql语句文件
$HIVE_HOME/bin/hive -f /home/my/hive-script.sql
#!/bin/bash #设置日志文件存放目录 cd / cd /home/deploy/recsys/workspace yesterday=$(date -d '-1 day' '+%Y-%m-%d') $HIVE_HOME/bin/hive -e "use mydb;ALTER TABLE mytable ADD PARTITION (dt = '$yesterday') LOCATION '/user/hive/warehouse/tail/$yesterday/';" #$HIVE_HOME/bin/hive -e "use mydb;select msec from mytable where dt='2015-01-07'"
相关推荐
archive 2020-07-30
成长之路 2020-07-28
eternityzzy 2020-07-19
taisenki 2020-07-05
tugangkai 2020-07-05
SignalDu 2020-07-05
zlsdmx 2020-07-05
tomson 2020-07-05
tugangkai 2020-07-04
tomson 2020-07-05
Zhangdragonfly 2020-06-28
genshengxiao 2020-06-26
成长之路 2020-06-26
tomson 2020-06-26
蜗牛之窝 2020-06-26
成长之路 2020-06-25