Hive Shell Common operations

Source: Internet
Author: User

1. Two modes of this article command:

Interactive mode, the shell environment for hive:hive > ....

Non-interactive mode: normal Linux command mode :% ... ..

2.Hive Shell Common operations

1) Hive-e: Executes the specified HQL from the command line and does not require a semicolon :

% hive-e ' select * from dummy ' > a.txt

2) hive–f: Execute hql Script

% hive-f/home/my/hive-script.sql

3) Hive-i: Executes the initialization SQL file before entering interactive mode

% Hive-i/home/my/hive-init.sql

4) hive-v: Output execution of the HQL statement to the console

5) hive-s: Display only running results, no additional information is displayed:

% hive-s-E ' select * from dummy '

Special commands in 3.Hive interactive mode:

Using a! Prefix to run the command that hosts the operating system, which is the Operation command for Linux. hive > a! ....

Use the DFS command to access the Hadoop file system, that is, to execute the Hadoop command. Hive > Dfs ....

4. Save Query Results

The first way:

    % hive-e ' select * from dummy ' > a.txt

The second way:

    hive > Insert overwrite local directory '/root/hive/a.txt ' select * from logs sort by TS;  

5. Here is a method for generating a single-Line table:

% echo ' x ' >/tmp/dummy.txt

% hive-e "CREATE table dummy (value string); \

Load data local inpath '/tmp/dummy.txt ' overwrite into table dummy "

Local means copying files from the native Linux system to the '/user/hive/warehouse/' directory on the HDFS system.

overwrite means overwrite write, that is, delete the original file, and then write the local data. If this keyword is omitted, hive simply adds the new data file to the directory.

Hive Shell Common operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.