HiveQL: View

A concept

View allows you to save a query and can treat the same table to the query operation. This is a logical structure, in other words, hive does not currently support materialized views.

1. Use a view to reduce the complexity of the query

- Create a view of 
the CREATE  the VIEW TB1 the AS 
the SELECT  *  the FROM T1 the JOIN T2
 the ON t1.id = t2.id; 

- obtaining data from the view in 
the SELECT  *  the FROM TB1 the WHERE ...

2. Use views to limit the filtered data based on the condition

/ * 
1. Some databases allow to view as a security mechanism, i.e. the original table does not have direct access to the user sensitive data, but to provide the user with a view of the restriction by WHERE, for access. 
2.HIVE currently does not support sub-function, because the user must have permission to access to the entire ground floor of the original table, view at this time to work. 
3. Therefore, to restrict data access by creating a view that can be used to protect information from being random queries. 
* / 
The CREATE  the VIEW techops_employee
 the SELECT  *  the FROM Employee the WHERE Department =  ' TechOps ' ;
 - Such a data table may be partitioned from view by, can play a role in dividing the data access permissions.

3. Dynamic view of the partition and the map type

/ * 
Create a view with dynamic partitioning, the other slightly 
* /

4. Characteristics of view

- 1. The definition of a view without actually 'concrete' no operation data, the view is actually used for its curing process tables and columns. 
- 2. For IF NOT EXITS and COMMENT are available, and creating tables are the same meaning. 
- 3. The view is read-only.    
- 4. The operation command once 
    the DROP  the VIEW  the IF EXITS Shipments - Delete View 
    SHOW TABLES - View View 
    the DESCRIBE TABLE  / describle EXTended TABLE  - see view metadata information

 

Guess you like

Origin www.cnblogs.com/lijingang/p/11390817.html