The view is a virtual table in PostgreSQL that does not store any data, since it has no physical existence as such.
CREATE [TEMP | TEMPORARY] VIEW name AS SELECT column_1, column_2, column_3,...... FROM table WHERE view_conditions;
name: It is used to specify the name of the PostgreSQL VIEW to be created.
CREATE VIEW stud AS SELECT “STUDENT_ID”, “STUDENT_AGE” FROM “STUDENTS” ;
Query returned successfully with no result in 30 msec.
The above query is executed to create a view called stud. In order to check the PostgreSQL VIEW, another query needs to be executed.
PostgreSQL DROP VIEW
To entirely remove or delete a PostgreSQL VIEW, the DROP VIEW statement is used.
DROP VIEW [IF EXISTS] name;
name: It is used to specify the name of the PostgreSQL VIEW to be deleted.
DROP VIEW stud;
In the above example, we are deleting or removing the PostgreSQL VIEW stud. After the execution, the PostgreSQL VIEW stud, will be completely deleted, if it exists, otherwise an error will be displayed.
Drop View using UI:
- Right-click on the selected view.
- Click on Delete/Drop option.
- Click on the “Yes” button from the pop-up generated.
- The View is thus dropped permanently.