Creating views in PostGIS
In a database, a view is a stored query. Every time that you open it, the query is run and fresh results are generated. To use views as layers in QGIS takes a couple of steps.
Getting ready
For this recipe, you'll need a query that returns results containing a geometry. The example that we'll use here is the query from the Joining tables in databases recipe where attributes were joined 1:1 between the census polygons and the population CSV.
How to do it…
The SQL method is described as follows:
- In Database | DB Manager, open SQL Window.
- Write a query; in this example, this is the join query that was written in the previous exercise. If you want to see it right away but not necessarily retain it, check the Load as new layer
Get QGIS: Becoming a GIS Power User now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.