Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added examples for HIVE-7136

...

  • Example of running a query from the command line

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

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

    No Format
       $HIVE_HOME/bin/hive -S -e 'select a.col from tab1 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 Hive 0.14)

    No Format
       $HIVE_HOME/bin/hive -f hdfs://<namenode>:<port>/hive-script.sql
       $HIVE_HOME/bin/hive -f s3://mys3bucket/s3-script.sql 
  • Example of running an initialization script before entering interactive mode

    No Format
       $HIVE_HOME/bin/hive -i /home/my/hive-init.sql
       

...

  • hive -e '<query-string>' executes the query string.
  • hive -f <filepath> executes one or more SQL queries from a file.
Info
titleVersion 0.14
As of Hive 0.14, <filepath> can be from one of the hadoop supported filesystems (hdfs, s3 etc) as well
$HIVE_HOME/bin/hive -f hdfs://<namenode>:<port>/hive-script.sql $HIVE_HOME/bin/hive -f s3://mys3bucket/s3-script.

...

sql 

See HIVE-7136 for more details.

 Examples are shown above.

Hive Interactive Shell Commands

...