Run $ HIVE_HOMEbinhive on a linux terminal to enter the interactive mode; $ HIVE_HOMEbinhive-e or-f is always in non-interactive mode 1. Execute the HQL statement in non-interactive mode $ HIVE_HOMEbinhive-eselect * frommovielimit10 to see mapreduce progress, but it does not enter the hive interaction mode, and the final real-world Query
Run $ HIVE_HOME/bin/hive on a linux terminal to enter the interaction mode; $ HIVE_HOME/bin/hive-e or-f are always in non-interactive mode. 1. Execute the HQL statement $ HIVE_HOME/bin/hive-e select * from movie limit 10 to implement mapreduce. progress, but it does not enter the hive interaction mode, and the final real-world Query
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
[hadoop@gaoyuan 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=true1113382172063197110411095751161610611978771214588122118913751710140623
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