zhuanzi: http://blog.csdn.net/u010220089/article/details/49231705
1、bin/hive -help
- bin/hive -help
- 15/10/18 06:34:46 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect. Use hive.hmshandler.retry.* instead
- usage: hive
- -d,--define <keykey=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 <propertyproperty=value> Use value for given property
- --hivevar <keykey=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
2、hive -e 用法
- [root@cloud1 hive-0.13.1]# bin/hive -e 'select * from default.student'
- 15/10/18 06:55:27 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect. Use hive.hmshandler.retry.* instead
-
-
- Logging initialized using configuration in jar:file:/opt/hive-0.13.1/lib/hive-common-0.13.1.jar!/hive-log4j.properties
- OK
- 1 xiaoming
- 2 zhangsan
- 3 lisi
- Time taken: 21.298 seconds, Fetched: 3 row(s)
hkl曰:我们什么情景下使用这个呢?
这种用法我们就不用进入到hive模式直接就可以来做。我们在脚本里执行的时候也可以用这个。
3、hive -f 用法
- [root@cloud1 hive-0.13.1]# touch hfile.sql
- [root@cloud1 hive-0.13.1]# vi hfile.sql
- select * from default.student ;
- bin/hive -f /opt/hive-0.13.1/hfile.sql
- [root@cloud1 hive-0.13.1]# bin/hive -f /opt/hive-0.13.1/hfile.sql
- 15/10/18 07:00:12 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect. Use hive.hmshandler.retry.* instead
-
-
- Logging initialized using configuration in jar:file:/opt/hive-0.13.1/lib/hive-common-0.13.1.jar!/hive-log4j.properties
- OK
- 1 xiaoming
- 2 zhangsan
- 3 lisi
- Time taken: 13.048 seconds, Fetched: 3 row(s)
-
- 或者: bin/hive -f hdfs://192.168.80.20:8020/user/hive/hfile.sql
4、hive -i 用法:(这里占时还没有例子)
* bin/hive -i xx
-i <filename> Initialization SQL file
eg:
add jar xxx.jar
add file xxx
create temporary function my_lower as ....
bin/hive -i hive-init.sql