6

Using QGIS 2.14.0 on a Microsoft Surface Book with Windows 10, I created a geopackage from a layer using Save As...

I can successfully add a field to the geopackage's attribute table, calculate changes to its values, and then save the changes.

However, when I try to delete that field, QGIS responds with "Provider does not support deleting fields". Sure enough, the field cannot be deleted. Please see attached image.

If I repeat the process, instead using either a shapefile or a spatialite layer, I can delete the attribute field. So the problem seems to be with the geopackage.

In summary, how do I delete a geopackage attribute table field?

enter image description here

  • 4
    Looks like is it an sqlite issue that is not supported hub.qgis.org/issues/8143 ('design choices') – Mapperz Mar 28 '16 at 1:17
  • 1
    Probably easiest just to create a new view which only has the required attributes, and save that. – BradHards Mar 28 '16 at 3:23
  • So, as I now understand, Geopackage is built on top of Spatialite, which in turn is built on top of Sqlite. Since Sqlite does not allow fields to be deleted or renamed (!!!), neither will Geopackage or Spatialite (although I was able to delete a field in Spatialite). Guess I'll be sadly sticking with shapefiles until this is resolved... – Stu Smith Mar 28 '16 at 4:28
  • 2
    Partly right. Geopackage is built on top of SQLite but SpatiaLite is a separate implementation that is also built on top of SQLite. SQLite does not support deleting columns with "ALTER TABLE" sqlite.org/lang_altertable.html but there are documented ways to implement that in an application. Therefore you can do it with SpatiaLite in QGIS. Make a feature request for QGIS and meanwhile use for example the workaround suggested by Brad. You may also be able to adjust your workflow so that you can drop the unwanted fields during creation time. – user30184 Mar 28 '16 at 8:33
  • Ok, Spatialite is in and Geopackage is out! – Stu Smith Mar 29 '16 at 4:19
3

GeoPackage is a SQLIte database, So you can edit the table with a program for manage databases.

Per example, you could to use "DBeaver", or you could to use "SQLite Expert Personal" (freeware).

With SQLite Expert you could to delete and reorder fields.

  • I think most of this is now in the standard / free version of DBeaver. – DPSSpatial Aug 21 '18 at 16:20
0

As mentioned above it is now possible to delete fields in a Geopackage in QGIS 3.6, using the same method as posted by the question asker.

Simply add the layer you'd like to edit the attributes of into a project and remove the fields either by using the "Delete field" button or by using the field calculator.

When you save your edits, it will also save the changes within the Geopackage.

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.