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.