[postgis-users] Creating an ID field in a view
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Thu Mar 29 09:02:46 PDT 2007
On Thu, 2007-03-29 at 17:15 +0200, Jose Gomez-Dans wrote:
> Hi!
> Beginner's warning :)
>
> I am tryingn to create a view which is the result of I a
> GeometryUnion betwen polygon tables. Hopefully, I will get a lot of
> split entries. If I then want to represent the results using QGIS (and
> for my own purposes), I need to create an unique field per feature. Is
> there some function which will add this field and populate it
> accordingly? I am not interested in its value, only in the fact that
> it has to be unique for each feature in the view.
>
> Can anyone shed any light? I have gone through the documentation, but
> I haven't actually seen anything which seems related.
>
> Many thanks,
> jose
Hi Jose,
If you don't care if the value changes each time you run the query,
simply create a sequence and reference it in your SELECT, e.g.
CREATE SEQUENCE foo CYCLE;
SELECT nextval('foo') AS id, the_geom FROM .... etc.
Kind regards,
Mark.
More information about the postgis-users
mailing list