Hive (12): View view

1 The concept of View

A view in Hive is a virtual table that only saves the definition and does not actually store the data. Generated views are usually created from actual physical table queries, and new views can also be created from existing views.

When a view is created, the view's schema is frozen, if the underlying table is dropped or changed, the view will fail, and the view cannot store data, manipulate data, only query.

In a nutshell: the view is used to simplify operations, it is actually a virtual table, records are not buffered in the view, and query performance is not improved.

2 View related syntax

--hive中有一张真实的基础表t_usa_covid19
select * from handsome.t_usa_covid19;

--1、创建视图
create view v_usa_covid19 as select count_date, county,state,deaths from t_usa_covid19 limit 5;

--能否从已有的视图中创建视图呢  可以的
create view v_usa_covid19_from_view as select * from v_usa_covid19 limit 2;

--2、显示当前已有的视图 
show tables;
show views;--hive v2.2.0之后支持

--3、视图的查询使用
se

Guess you like

Origin blog.csdn.net/u013938578/article/details/131423981