Gis Tricks

Adding primary key postgis

Adding primary key postgis

Sometimes you have a result in a postgis table, but cannot edit the result or view it in QGis. Primary key postgisEverytime that happens I keep looking up the same thing. Simply adding a primary key into the table. It is easy, you just have to know how:


ALTER TABLE <table> ADD COLUMN <column> BIGSERIAL PRIMARY KEY;

In my case:


ALTER TABLE lines ADD COLUMN gidpk BIGSERIAL PRIMARY KEY;

See also postgres manual

 

2 thoughts on “Adding primary key postgis

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × 3 =