Today we are going to learn PGAdmin how to create a view. Most of time we have to reuse the same queries multiple time in our project, we can achieve it using the view option of PGAdmin, we can save the SQL queries under Views.
This is one of the best and short steps to create view:
- Right click on the Views option under the DataBaseName -> schemas -> Public -> Views and click on New View as shown on the below snapshot:
- After that a new window will open asking for new View name under properties and SQL query under Definition button as shown on the below snapshots:
- After that click OK and save the query.
Steps for using the view:
- After successfully saving the query in view, we can call the view in our SQL query and use it as shown on the below query:
select * from view_form_name;
- We can also use it with WHERE condition:
SELECT * FROM view_form_name WHERE name LIKE '%john%';