- Impala - Query Language Basics
- Impala - Shell
- Impala - Architecture
- Impala - Environment
- Impala - Overview
- Impala - Home
Database Specific Statements
Table Specific Statements
- Impala - Drop a View
- Impala - Alter View
- Impala - Create View
- Impala - Show Tables
- Impala - Truncate a Table
- Impala - Drop a Table
- Impala - Alter Table
- Impala - Describe Statement
- Impala - Select Statement
- Impala - Insert Statement
- Impala - Create Table Statement
Impala - Clauses
- Impala - Distinct Operator
- Impala - With Clause
- Impala - Union Clause
- Impala - Offset Clause
- Impala - Limit Clause
- Impala - Having Clause
- Impala - Group By Clause
- Impala - Order By Clause
Impala Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Impala - Alter View
The Alter View statement of Impala is used to change a view. Using this statement, you can change the name of a view, change the database, and the query associated with it.
Since a view is a logical construct, no physical data will be affected by the alter view query.
Syntax
Following is the syntax of the Alter View statement
ALTER VIEW database_name.view_name as Select statement
Example
For example, assume we have a view named customers_view in the my_db database in Impala with the following contents.
+----------+-----+ | name | age | +----------+-----+ | Komal | 22 | | Khilan | 25 | | Ramesh | 32 | | Hardik | 27 | | Chaitap | 25 | | kaushik | 23 | +----------+-----+
Following is an example of Alter View Statement. In this example, we are including the columns id, name, and salary instead of name and age to the customers_view.
[quickstart.cloudera:21000] > Alter view customers_view as select id, name, salary from customers;
On executing the above query, Impala does the specified changes to the customers_view, displaying the following message.
Query: alter view customers_view as select id, name, salary from customers
Verification
You can verify the contents of the view named customers_view, using the select statement as shown below.
[quickstart.cloudera:21000] > select * from customers_view; Query: select * from customers_view
This will produce the following result.
+----+----------+--------+ | id | name | salary | +----+----------+--------+ | 3 | kaushik | 30000 | | 2 | Khilan | 15000 | | 5 | Hardik | 40000 | | 6 | Komal | 32000 | | 1 | Ramesh | 20000 | | 4 | Chaitap | 35000 | +----+----------+--------+ Fetched 6 row(s) in 0.69s
Altering a View using Hue
Open Impala Query editor, select the context as my_db, and type the Alter View statement in it and cpck on the execute button as shown in the following screenshot.
After executing the query, the view named sample will be altered accordingly.
Advertisements