I have a shapefile with a "id" field in which some non-unique ID numbers exist (don't ask).

When I try to import this to a PostGIS database using QGIS' DB Manager, it tries to re-use those IDs are unique primary key and fails.

The "Primary key" option is not ticked. "id" is shown in grey next to it. screenshot

How can I make DB Manager ignore an existing "id" column and just create a new SERIAL field or something like that?

QGIS 2.18.

1 Answer 1


Possibility 1: Delete the "id" field in the data you want to import before

Possibility 2: Define a new Primary Key: Tick the "Primary key" option and name it like "gid" or "fid" or whatever and after that delete the original "id" with double entries (or not).

  • 1
    The dialog does not make it clear at all that the Primary Key option allows the user to name the column that QGIS will *create. I assumed this was selecting a column from the data-to-be-uploaded. Thanks! Jul 3, 2018 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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