In PostgreSQL, a VIEW is a pseudo table. It is not a physical table but appear as ordinary table to select.
A view can also represent joined tables. It can contain all rows of a table or selected rows from one or more tables.
A View facilitates users to do the following:
PostgreSQL Create View
PostgreSQL view can be created by using CREATE VIEW statement. You can create it from a single table, multiple tables and another view.
PostgreSQL Create View Example
Consider a table "EMPLOYEES", having the following data.
Now, we create a view from "EMPLOYEES" table. This view would contain only few columns from EMPLOYEES table:
Execute the following query:
You can see this as:
Now, you can retrieve data from the view "current_employees" as a simple query statement. You would see the following table:
PostgreSQL DROP View
Follow these steps:
You can also delete or drop a view by using the DROP VIEW command.
To delete the above example: