Hive Indexes and View with Example

What is a View?

Views are similar to tables, which are generated based on the requirements.

Creation of View:

Syntax:

Create VIEW <VIEWNAME> AS SELECT

Example:

Hive>Create VIEW Sample_ViewAS SELECT * FROM employees WHERE salary>25000

In this example, we are creating view Sample_View where it will display all the row values with salary field greater than 25000.

What is Index?

Indexes are pointers to particular column name of a table.

Syntax:

Create INDEX <INDEX_NAME> ON TABLE < TABLE_NAME(column names)>

Example:

Create INDEX sample_Index ON TABLE guruhive_internaltable(id)

Here we are creating index on table guruhive_internaltable for column name id.

 

YOU MIGHT LIKE: