Commonly used Apache Hive Command Line Options and Examples

  • Post author:
  • Post last modified:November 2, 2019
  • Post category:BigData
  • Reading time:4 mins read

You can use the Hive shell interactive tool (hive) to set up databases and tables, insert data, and issue queries. If you have worked on Netezza or Oracle, this tool is similar to nzsql or SQLPlus. For ad hoc queries and data exploration, you can submit SQL statements in an interactive session. You can write the queries in the script file and execute those using Hive shell Command Line Options.

Read:

Apache Hive Command Line Options

Apache Hive Command Line Options

Below are the commonly used Apache Hive command line options:

Hive Command Line Option Description
-d,–define <key=value> Variable substitution to apply to Hive commands.

e.g. -d A=B or –define A=B

-e <quoted-query-string> Execute SQL from command line.

e.g. -e ‘select * from table1’

-f <filename> Execute SQL from file. e.g. -f ‘/home/sql_file.sql’
-H,–help Print Hive help information. Usually, print all command line options.
-h <hostname> Connect to host server in case if connecting from remote host
–hiveconf <property=value> Use value for given property. For example –hiveconf hive.cli.errors.ignore=false
–hivevar <key=value> Variable substitution to apply to Hive commands.

e.g. –hivevar A=B

-i <filename> Initialization SQL file
-p <port> Hive Server port number
-S,–silent Silent mode in interactive shell
-v,–verbose Verbose mode (echo executed SQL to the console)

Hive Command Line Options Usage Examples

Execute query using hive command line options

$ hive -e 'select * from test';

Execute query using hive command line options in silent mode

$ hive -S -e 'select * from test'

Dump data to the file in silent mode

$hive -S -e 'select col from tab1' > a.txt

Read: