Impala - Drop a View



The Drop View query of Impala is used to delete an existing view. Since a view is a logical construct, no physical data will be affected by the drop view query.

Syntax

Following is the syntax of the drop view statement.

DROP VIEW database_name.view_name;

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  | 
| Chaitali | 25  | 
| kaushik  | 23  | 
+----------+-----+

Following is an example of Drop View Statement. In this example, we are trying to delete the view named customers_view using the drop view query.

[quickstart.cloudera:21000] > Drop view customers_view;

On executing the above query, Impala deletes the specified view, displaying the following message.

Query: drop view customers_view

Verification

If you verify the list of tables using show tables statement, you can observe that the view named customers_view is deleted.

[quickstart.cloudera:21000] > show tables;

This will produce the following result.

Query: show tables 
+-----------+ 
| name      | 
+-----------+ 
| customers | 
| employee  | 
| sample    | 
+-----------+ 
Fetched 3 row(s) in 0.10s

Dropping a View using Hue

Open Impala Query editor, select the context as my_db, and type the Drop view statement in it and click on the execute button as shown in the following screenshot.

Dropping a View

After executing the query, if you scroll down, you can see a list named TABLES. This list contains all the tables and views in the current database. From this list, you can find that the specified view was deleted.

Dropping a View Tables
Advertisements