Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic operations of Hive

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the basic operation of Hive, which is very detailed and has a certain reference value. Friends who are interested must read it!

Hive (introduction)

What is 20180717Hive?

Hive- Foundation

Hive is an indispensable tool in Hadoop biosphere system.

Hive provides a SQL dialect called Hive query language (HiveQL or HQL for short) to query data stored in an Hadoop cluster

Hive is not a complete database and does not support record-level update, insert or delete operations, but can generate new tables through queries or import query results into files

In Hive, even if the dataset is relatively small, it often takes a long time to execute

-- Hive does not support transaction level operations

-- the "use once" command in Hive

$hive-e "SELECT * FROM yytable LIMIT 3"

OK

Zs 10

Ls 20

Ww 30

Time taken: 4.449 seconds

In case of temporary emergency, you can use this function to save the query file to a file.

$hive-e "SELECT * FROM yytable LIMIT 3" > / tmp/test

$cat / tmp/test/

Zs 10

Ls 20

Ww 30

Database in Hive

If the user does not display the custom database, the default database default is used.

Hive creates a directory for each database. The tables in the database will be stored as subdirectories of the database directory.

One exception is the tables in the default database, because the database itself does not have its own directory.

-- create a database

Hive > CREATE DATABASE tmp

If the database tmp already exists, an error message will be thrown, which can be avoided by using the following statement

Hive > CREATE DATABASE IF NOT EXISTS tmp

-- View the database

Hive > SHOW DATABASES

Default

Tmp

If there are a large number of databases, you can use regular expressions to filter the database names you need.

Hive > SHOW DATABASES LIKE 't.girls'

Tmp

-- switching databases

The USE command is used to switch a database to the database you want to go to.

Hive > USE tmp

-- delete the database

Hive > DROP DATABASE IF EXISTS tmp

By default, Hive does not allow users to delete a database that contains tables

Users either delete the tables in the database first, then delete the database, or add the keyword CASCADE at the end of the delete command, so that Hive deletes the tables in the database first.

Hive > DROP DATABASE IF EXISTS tmp CASCADE

If you use the keyword RESTRICT, as by default, if you want to delete the database, delete the table first.

The above is all the contents of the article "what are the basic operations of Hive". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report