启动 hive 的方式
[root@hadoop10 hive2.3.6]# hive --heip -d,--define <key=value> Variable substitution 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 --hiveconf <property=value> Use value for given property --hivevar <key=value> Variable substitution to apply to Hive commands. e.g. --hivevar A=B -i <filename> Initialization SQL file -S,--silent Silent mode in interactive shell -v,--verbose Verbose mode (echo executed SQL to the console)
-e:不进入 shell,在 linux 命令行执行 sql
[root@hadoop10 hive2.3.6]# hive -e ‘select * from hive1.hive_01 limit 10‘;
注意指定 数据库和数据表
-f:在文件中执行 sql
把 sql 语句写入文件,随便什么文件格式
[root@hadoop10 hive2.3.6]# hive -f sql.sh
hive> dfs - ls /;
hive> ! ls /usr/lib/hive2.3.6; bin binary-package-licenses conf examples
未完待续...
原文:https://www.cnblogs.com/yanshw/p/11780752.html