[postgis-users] QGIS requires

Nicolas Ribot nicolas.ribot at gmail.com
Wed Aug 18 11:12:23 PDT 2010


On 18 August 2010 19:51, William Furnass <will at thearete.co.uk> wrote:
> Hi,
>
> QGIS requires that all PostGIS tables/views have a numeric primary
> key.  As a result I have had to create many temporary tables solely
> for the purpose of viewing the results of queries when ideally I would
> have liked to create views from the majority of my queries.  Does
> anyone know if I can create on-the-fly a serial numeric column in
> queries/views to save me having to create so many temporary tables?
> It'd be grand if something like the following were possible:
>
> CREATE VIEW my_view AS (SELECT numeric_id_generator(),
> St_Union(wkb_geometry) FROM my_subregions GROUP BY region_id);
>
> Cheers,
>
> Will

Hi,

If you control the table creation, or if you can recreate them, you
can enable oids on the table: this hidden column stores a unique
identifier and qgis seems to use it to identify geometries. (oids are
disabled by default on recent postgresql versions, to avoid a
potential problem if the total number of records in the database
exceed the integer type limit (~4 billions. see:
http://www.postgresql.org/docs/8.4/static/ddl-system-columns.html).

Otherwise, a sequence will do the trick, as Aman ( fastly ;) ) noted.

Nicolas



More information about the postgis-users mailing list