Shell regularly creates Hive table partitions and shellhive partitions

Source: Internet
Author: User

Shell regularly creates Hive table partitions and shellhive partitions


First, let's take a look at the hive help command:

[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    --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 


Use crontab to add table partitions to hive tables:




Method 1:

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


Run the following command:

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


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






Method 2:

-i <filename>                    Initialization SQL file

Edit the SQL command:

Alter table gcldlog add partition (dt = '2017-06-10 ') location '2017-06-10 ';

Exit; (remember to add the exit command)


Run the following command:

Hive -- database gcld-I/script/gcld/test. SQL;




In this way, shell can dynamically add partition tables to hive tables.









Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.