7

Is it possible to edit POSTGIS tables directly in QGIS 2.6.1. I've been using The DB MANAGER but can only really do DDL type edits....Or create/import a brand new layer. I did see a SQL Window but that would be too complex for my customers to navigate. I believe in the past I've seen a Plugin or something to do this but from what I've read the DB Manager is the plugin of the future for Postgis.

An alternative is to pull into QGIS, Save as a shapefile and then re-publish to POSTGIS. This approach doesn't work well in our environment.

I'd like to be able to edit PostGIS directly via some type of Table Edit (similar to what I can do with shapefiles in ArcGIS).

2 Answers 2

6

Yes, you can edit both spatial and non-spatial PostGIS tables within QGIS.

  1. Make sure your PostgresSQL DB is PostGIS enabled
  2. Use the Add PostGIS layers button to first make a connection to a PostgresSQL db
  3. Next, use the Connect button to connect to DB to add both spatial and non-spatial tables
  4. Finally, select the layer in the QGIS TOC, then click the Toggle Editing button to start the edit session (you can draw new features, delete features, and open the attribute table to update record values)

Here are some links that give more details:

Working with your PostGIS Layers using QGIS

4
  • Note: Spatial tables will only show up in QGIS if they are in your database's geometry_column table. Otherwise they will be considered 'non-spatial' and, like @artwork21 posted, you'll need to select non-spatial tables in the connection window to see it.
    – Roman
    Commented Feb 24, 2015 at 19:41
  • @Roman, there is a check box that you can List all tables with no geometry and add them within QGIS via Add PostGIS tables dialog.
    – artwork21
    Commented Feb 24, 2015 at 19:51
  • Also note that you can edit postgis views in qgis if you implement instead of trigger actions in the db.
    – Jakob
    Commented Feb 25, 2015 at 7:03
  • Thanks guys, I got it working. Looks like the db user I was using only had read permissions on these objects so the toggle button wasn't even shown. I modified the db permissions and it showed up. I wouldn't of expected that behavior but seems like that was the case. But looks like everythying is good now! Thanks Commented Feb 26, 2015 at 13:54
2

If you can't edit your table data and don't know why, check that your table has a primary key. You might have to re-add the layer to your QGIS project for it to recognize the key and allow editing.

1
  • Add a primary key to an existing table with ALTER TABLE schema."TABLE_NAME" ADD PRIMARY KEY ("COLUMN");
    – adm-gis
    Commented May 16 at 19:21

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.