VIEW in HIVE is similar to what we have in the RDBMS system.The concept of VIEW has been incorporated from the RDBMS .It allows us to store the Query and treat it like as Table.It does not store the data.
Some of the basic functions of a VIEW are :-
1.) To reduce query complexity.
2.)To reduce the data on the basis of some condition.
3.)Query a view is like querying a table.
4.)If a query references a table, then the definition of the view is combined with the rest of the query by Hive's query planner.
5.)Query using the view can fail, if the referenced table/column does not exist.
CREATING A VIEW
To create any view , we need an underlying table on which we have to create our query.
Let us take a simple example with employees table and we will align our query on this table.
we have the below data:-
we want to have only those id which are having salary more than 50000.
Syntax :-
create view view name as select column name from referenced_table;
The select * from viewemp will give us the below result.
The view is available in the database just like the normal table , we will get the view name if we give the show tables;
we should note that we can create index on the view and can join two views also .
Dropping a View :-
drop view viewname;
Some of the basic functions of a VIEW are :-
1.) To reduce query complexity.
2.)To reduce the data on the basis of some condition.
3.)Query a view is like querying a table.
4.)If a query references a table, then the definition of the view is combined with the rest of the query by Hive's query planner.
5.)Query using the view can fail, if the referenced table/column does not exist.
CREATING A VIEW
To create any view , we need an underlying table on which we have to create our query.
Let us take a simple example with employees table and we will align our query on this table.
we have the below data:-
we want to have only those id which are having salary more than 50000.
Syntax :-
create view view name as select column name from referenced_table;
The select * from viewemp will give us the below result.
The view is available in the database just like the normal table , we will get the view name if we give the show tables;
we should note that we can create index on the view and can join two views also .
Dropping a View :-
drop view viewname;
No comments:
Post a Comment