Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
usage: 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
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable subsitution 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)
 

Example

  • Example of running a query from the command line

    No Format
     $HIVE_HOME/bin/hive -e 'select a.foo from pokes a'
     
  • Example of setting Hive configuration variables

    No Format
     $HIVE_HOME/bin/hive -e 'select a.foo from pokes a' --hiveconf hive.exec.scratchdir=/opt/my/hive_scratch --hiveconf mapred.reduce.tasks=1
     
  • Example of dumping data out from a query into a file using silent mode

    No Format
    $HIVE_HOME/bin/hive -S -e 'select a.foo from pokes a'> a.txt
     
  • Example of running a script non-interactively from local disk

    No Format
     $HIVE_HOME/bin/hive -f /home/my/hive-script.sql
     
  • Example of running a script non-interactively from a Hadoop supported filesystem (starting in Hive 0.14)

    No Format
    $HIVE_HOME/bin/hive -f hdfs://<namenode>:<port>/hive-script.sql

...