Impala ALTER VIEW Statement – How to Alter a View
In our last Impala Tutorial, we saw Create & Drop View Statements. Here, we are going to discuss Impala Alter View Statement. It helps to change the query associated with a view in Impala.
Moreover, we will discuss the whole concept of Impala ALTER VIEW from its introduction, syntax, type as well as its example, to understand it well.
So, let’s start Impala Alter View Statements.
Impala ALTER VIEW Statement
Impala ALTER VIEW Statement changes the query associated with a view, or the associated database and/or name of the view in Impala.Â
However, ALTER VIEW only involves changes to metadata in the Metastore database, because a view is purely a logical construct (an alias for a query) with no physical data behind it, not any data files in HDFS.
a. Syntax for Alter View Statement
So, the syntax for using ALTER VIEW Statement in Impala is-
ALTER VIEW [database_name.]view_name AS select_statement ALTER VIEW [database_name.]view_name RENAME TO [database_name.]view_name
b. Statement type
Impala ALTER VIEW Statement is of DDL Type.
Examples – Impala Alter View Statement
Let’s take an example of Impala alter a view,
Let us suppose we have a table named Employees in the database my_db. Its contents are
name | age |
shubham | 32 |
monika | 25 |
kajal | 27 |
revti | 25 |
shreyash | 23 |
mehul | 22 |
So, here is an example of the Impala Alter View Statement. Basically, using the Alter View Statement, we are including the columns id, name, and salary instead of name and age to the Employees_view.
[quickstart.cloudera:21000] > Alter view Employees_view as select id, name,
salary from Employees;
Impala does the specified changes to the Employees_view on executing the above query.
Query: alter view Employees_view as select id, name, salary from Employees
Verification
So, here we are verifying the contents of the view named Employees_view, using the Impala Alter view statement,
[quickstart.cloudera:21000] > select * from Employees_view;
Query: select * from Employees_view
Result is:
id | name | salary |
3 | kajal | 40000 |
2 | monika | 15000 |
5 | shreyash | 30000 |
6 | mehul | 32000 |
1 | shubham | 20000 |
4 | revti | 35000 |
Fetched 6 row(s) in 0.69s
Altering a View using Hue
Here are the following steps, we can follow for Altering a View using Hue:
- At first, type the Alter View statement in Impala Query editor. Further, select the context as my_db, then click on the execute button.
- Â The view named sample will be altered accordingly, just after executing the query.
So, this was all about Impala Alter View Statements. Hope you like
Conclusion
As a result, we have seen the whole concept of Impala Alter View Statement. Still, if any doubt occurs in how to alter the data in the view, feel free to ask in the comment section.
Your opinion matters
Please write your valuable feedback about DataFlair on Google