欢迎投稿

今日深度:

shell定时创建Hive表分区

shell定时创建Hive表分区


首先看一下hive 的help命令:

[hdfs@xxx hive]$ hive  -h
Missing argument for option: h
usage: hive
 -d,--define <key=value>          Variable subsitution to apply to hive
                                  commands. e.g. -d A=B or --define A=B
    --database <databasename>     Specify the database to use
 -e <quoted-query-string>         SQL from command line
 -f <filename>                    SQL from files
 -H,--help                        Print help information
 -h <hostname>                    connecting to Hive Server on remote host
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable subsitution to apply to hive
                                  commands. e.g. --hivevar A=B
 -i <filename>                    Initialization SQL file
 -p <port>                        connecting to Hive Server on port number
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the
                                  console)
[hdfs@xxxx <span style="font-family: Arial, Helvetica, sans-serif;">hive]$ </span>


使用crontab定时给hive表增加表分区:

方法1:

 -e <quoted-query-string>         SQL from command line

执行命令:

[hdfs@xxxx hive]$ hive --database gcld -e 'alter table gcldlog add partition (dt=\\'2015-06-14\\') location \\'2015-06-14\\'';


Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
OK
Time taken: 1.097 seconds

方法2:

-i <filename>                    Initialization SQL file

编辑好sql命令:

alter table gcldlog add partition (dt=‘2015-06-10') location '2015-06-10';

exit;(记得加上退出命令)

执行命令:

hive --database gcld -i /script/gcld/test.sql ;




这样就可以实现shell动态给hive表增加分区表的操作。

www.htsjk.Com true http://www.htsjk.com/sybase/19769.html NewsArticle shell定时创建Hive表分区 首先看一下hive 的help命令: [hdfs@xxx hive]$ hive -hMissing argument for option: husage: hive -d,--define key=value Variable subsitution to apply to hive commands. e.g. -d A=B or --define A=B --databa...
相关文章
    暂无相关文章
评论暂时关闭