Run $ HIVE_HOME/bin/hive on a linux Terminal to enter the interaction mode;
$ HIVE_HOME/bin/hive-e or-f is always in non-interactive mode.
1. Execute HQL statements in non-interactive mode
$ HIVE_HOME/bin/hive-e 'select * from movie limit 10'
Mapreduce progress will be realized, but it will not enter the hive interaction mode, and the final query result will be
2. Execute HQL statements in non-interactive mode (-S mute mode)
$ HIVE_HOME/bin/hive-S-e 'select * from movie limit 10'
Adding the-S option does not display the mapreduce progress
[[Email protected] hive-0.14] $ bin/hive-S-e 'select * from movie limit 10' SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar: file:/home/hadoop/hadoop-2.4.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar! /Org/slf4j/impl/StaticLoggerBinder. class] SLF4J: Found binding in [jar: file:/home/hadoop/hive-0.14/lib/hive-jdbc-0.14.0-SNAPSHOT-standalone.jar! /Org/slf4j/impl/StaticLoggerBinder. class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org. slf4j. impl. log4jLoggerFactory] Error rolling back: Can't call rollback when autocommit = true1113382172063197110411095751091610911978771214588122118913751710140623
3. Export hive query to a file
$ HIVE_HOME/bin/hive-S-e 'select * from movie limit 10'>/gaoyuan/ouput.txt
This will import the execution result of the hivequery statement to the output.txt file.
4. Run the hive script instead of entering hive interaction mode.
$ HIVE_HOME/bin/hive-f hiveScript. SQL
You can also save the output result to a file.
$ HIVE_HOME/bin/hive-f hiveScript. SQL>/home/username/output.txt
Hive non-interactive mode