Impala views
Provides information about using Views as lightweight logical constructs that can act as aliases for queries. Using a view, you can issue complicated reporting queries with compact and simple syntax and reduce maintenance by avoiding the duplication of complicated queries across multiple applications in multiple languages.
You can specify a view name in a query (a SELECT
statement or the
SELECT
portion of an INSERT
statement) where you would
usually specify a table name.
CREATE VIEW v2 AS SELECT t1.c1, t1.c2, t2.c3 FROM t1 JOIN t2 ON (t1.id = t2.id);
-- This simple query is safer to embed in reporting applications than the longer query above.
-- The view definition can remain stable even if the structure of the underlying tables changes.
SELECT c1, c2, c3 FROM v2;
A view lets you to:
- Build a new, more refined query on top of the original query by adding new clauses, select-list expressions, function calls, and so on: This technique lets you build up several more or less granular variations of the same query, and switch between them when appropriate.
- Set up aliases with intuitive names for tables, columns and result sets from joins.
- Avoid coding lengthy subqueries and repeating the same subquery text in many other queries.
To create, alter, or drop views, use the CREATE VIEW
, the ALTER
VIEW
, and the DROP VIEW
statements respectively.
You cannot insert into views.
To see the definition of a view, issue a DESCRIBE FORMATTED
statement,
which shows the query from the original CREATE VIEW
statement