Making spatial view in PostGIS and adding it as layer in QGIS?
I can confirm that it is not possible to simply select a listed view.
It seems necessary to select the "primary key column" first. Then the table turns selectable:
(Updating my answer slightly)
As long as the OBJECTID (row_number) field is first in the column definition of the view, QGIS will pick it up without asking you to add from the 'add vector layer' menu.
CREATE OR REPLACE VIEW dqmt.addressverify AS
SELECT row_number() OVER (ORDER BY newaddresses.addressid) AS objectid,
newaddresses.addressid
, geom
FROM dqmt.newaddresses;
I just fixed some old views that were broken as per the original question, but moving the OBJECTID field to the start of the view fixed the problem!
Does your view show up in the geometry_columns
table? According to the manual the view should automatically show up in 2.0 but I haven't tried it.
Try running the following to check:
SELECT f_geometry_column As col_name, type, srid, coord_dimension As ndims
FROM geometry_columns
WHERE f_table_name = 'my_spatial_table' AND f_table_schema = 'my_schema';