QGIS – Deleted Layer in Geopackage Still Visible in QGIS: How to Fix

dbmanagergeopackageqgis

I have created a multitable Geopackage as a Database. After some work, I decided to replace one layer with a different layer, so I created a new layer and deleted the old one via the DB-Manager in QGIS 3.22, as described e.g. in this thread.

The deleted table is still visible in the DB-Manager, however, and it also still appears as loadeable when connecting to the Geopackage via the Datasourcemanager. It is only displayed, it does not have any entries or fields, which apparently really where deleted. Since I allready have encountered a couple of bugs in the QGIS-DB-Manager, I wanted to make sure that the table isn't still in the database and opened the GeoPackage in DBeaver. The table was visible in DBeaver as well, so I deleted it again via DROP TABLE. In DBeaver it is gone now but in QGIS it still appears.

I have tried reloading the Geopackage in a new QGIS-Project and deleting and resetting the entire Database connection in the Datasourcemanager, but the table still appears in QGIS.

Is there any other workflow I must follow, to get rid of the layer in QGIS, or is this simply a bug?

Best Answer

QGIS sets the GeoPackage SQLite database into Write ahead logging (WAL) mode https://sqlite.org/wal.html. Changes that are made into a database from one connection will not exist for the other connections which were open at the time of editing. All the changes are written into the database at least when the last connection is closed. The .wal file disappears by the same. That is also a simple indicator for a user: if .wal file exists there are some changes pending and the database may look a bit different for each open connection.

Related Question