5

When I enter edit mode of a PostGIS layer in QGIS 1.8 and add a feature, is it possible to auto-increment the ID?

I always have to look what last used ID was and manually enter a new one. I can't believe I'm the first one facing this problem.

9

You should do that on your table in postgres

ALTER TABLE your_table ADD COLUMN idcolumn BIGSERIAL PRIMARY KEY;

QGIS will auto increment that ID for you, well Postgres does and QGIS will just read it back once you save.

  • Thanks for your answer. I'm creating my PostGIS tables with the QGIS plugin "PostGIS Manager". The clue was to choose the id column datatype as "BIGSERIAL" and not "INT". I had a primary key column wit integer data type before, but it works only with BIGSERIAL. – Conrad Jun 18 '13 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.