Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add links to admin docs for Hive Server & HiveServer2 (--service option)

...

No Format
usage: hive
 -d,--define <key=value>          Variable substitution to apply to hive
                                  commands. e.g. -d A=B or --define A=B
 -e <quoted-query-string>         SQL from command line
 -f <filename>                    SQL from files
 -H,--help                        Print help information
 -h <hostname>                    Connecting to Hive Server on remote host
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable substitution to apply to hive
                                  commands. e.g. --hivevar A=B
 -i <filename>                    Initialization SQL file
 -p <port>                        Connecting to Hive Server on port number
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the
                                  console)

See Variable Substitution for examples of using the hiveconf option.

Info
titleVersion information

As of Hive 0.10.0 there is one additional command line option:

Code Block
--database <dbname>      Specify the database to use

Another command line option, --service, can be used for the Hive Thrift Server or HiveServer2. See Hive Server and Setting Up HiveServer2.

Examples

See Variable Substitution for examples of using the hiveconf option.

  • Example of running a query from the command line
    Code Block
       $HIVE_HOME/bin/hive -e 'select a.col from tab1 a'
       
  • Example of setting Hive configuration variables
    Code Block
       $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
    Code Block
       $HIVE_HOME/bin/hive -S -e 'select a.col from tab1 a' > a.txt
       
  • Example of running a script non-interactively
    Code Block
       $HIVE_HOME/bin/hive -f /home/my/hive-script.sql
       
  • Example of running an initialization script before entering interactive mode
    Code Block
       $HIVE_HOME/bin/hive -i /home/my/hive-init.sql
       

...

Command

Description

quit
exit

Use quit or exit to leave the interactive shell.

reset

Resets the configuration to the default values (as of Hive 0.10: see HIVE-3202).

set <key>=<value>

Sets the value of a particular configuration variable (key).
Note: If you misspell the variable name, the CLI will not show an error.

set

Prints a list of configuration variables that are overridden by the user or Hive.

set -v

Prints all Hadoop and Hive configuration variables.

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b2e2818866661044-b29bfd36-42a44f3a-a0628cd2-87b0e8a2e5a4823590d27113"><ac:plain-text-body><![CDATA[

add FILE[S] <filepath> <filepath>*
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c28c05aad810cbf4-4f57214d-4e6d4836-a83abfc9-7a172782c2f859a41134459e"><ac:plain-text-body><![CDATA[add JAR[S] <filepath> <filepath>*
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3708c973f5f80e12-1c3f3c5f-4a184172-be449cbb-7d0fd0e1192bfb715abbdd13"><ac:plain-text-body><![CDATA[add ARCHIVE[S] <filepath> <filepath>*

Adds one or more files, jars, or archives to the list of resources in the distributed cache.

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c6941806b9480345-86550812-4a1b4b6b-9db7a2b2-7ef1086a8fa2da246c863b4e"><ac:plain-text-body><![CDATA[

list FILE[S]
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="12bc8fa04ffa6db8-2d3c6b3b-4c6a45c2-be5cbd69-8f42c5c7ddfbc04772c0f8f0"><ac:plain-text-body><![CDATA[list JAR[S]
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e52fff73a7bb2518-fd3d7504-444e4aee-9e1baf74-2cbba8b4054cd1580850f959"><ac:plain-text-body><![CDATA[list ARCHIVE[S]

Lists the resources already added to the distributed cache.

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7f99101c91ba61b4-48e726f8-48ee4abe-9eeeb7f8-91df821117213e3ceea2db6c"><ac:plain-text-body><![CDATA[

list FILE[S] <filepath>*
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="083d6744bb087404-3ce2bb98-42094c07-af7cb450-f7178cd76c4f109e6b3bf771"><ac:plain-text-body><![CDATA[list JAR[S] <filepath>*
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6fbb17e9526a4a98-98e69c9f-402e4212-94d8955a-edae19bcde1f31ce9ec42614"><ac:plain-text-body><![CDATA[list ARCHIVE[S] <filepath>*

Checks whether the given resources are already added to the distributed cache or not.

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="04b89478674be467-061cdf75-46c34863-b59faa54-0f4995985169cff767eed2b9"><ac:plain-text-body><![CDATA[

delete FILE[S] <filepath>*
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="69989e6f267e8c32-1bcfc1f8-42ba4d47-8365a658-1f095992ae0936d0e9ad15d9"><ac:plain-text-body><![CDATA[delete JAR[S] <filepath>*
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7a3b7048c23dbf21-85920537-455448be-beb6b8ae-18f788686836485eb05a45c2"><ac:plain-text-body><![CDATA[delete ARCHIVE[S] <filepath>*

Removes the resource(s) from the distributed cache.

]]></ac:plain-text-body></ac:structured-macro>

! <command>

Executes a shell command from the Hive shell.

dfs <dfs command>

Executes a dfs command from the Hive shell.

<query string>

Executes a Hive query and prints results to standard output.

source FILE <filepath>

Executes a script file inside the CLI.

...