Is there any way to refresh the attribute table of a layer after editing the table (e.g. add a column) in the DB-Manager?

  • the changeDataSource plugin is the fastest way and works very well with .csv files – scataldi Oct 10 '17 at 12:25

Short and sweet:

  1. Install changeDataSource plugin.
  2. Right-click on the layer in the Layers Panel and select Change vector datasource.
  3. In the dialog box that appears, just hit OK without changing any of the settings.

Basically, you are "changing" the vector datasource to what it already was, but this forces QGIS to reload the layer definition.

Tested in QGIS 2.14 on Linux Mint 17.2.

  • I've had to reselect the same datasource in order for that to work. – sladstaetter Jun 3 at 9:29

Assuming that your working with a PostGIS database, you can update the statistics of the table of interest by using the ANALYSE function: http://www.postgresql.org/docs/current/static/sql-analyze.html

In your case you can execute the statement inside the DB-manager by pressing the button marked in the attached image and executing the ANALYSE statement in the window, which is also marked. The query would be ANALYSE yourschema.yourtable.The analyse command should update your table, so that when you access the information again it should reflect the changes you have made. DB manager window

  • 1
    This doesn't refresh the attribute table (right click on layer -> Open Attribute Table). – Lunar Sea Apr 24 '16 at 6:47

Do I understand well if you mean to refresh the table in QGIS after a change to the columns is made?

As far as I know, only close and open the project or re-adding the table will make this happen. As long as you saved the default style in the database that might be the fastest way.

When a column is added with the Field Calculator the changes are instantly visible but the DB manager offers more control in defining the field type so I understand why that may not be a solution.

  • Is there any Python command to refresh the attribute table? I've also noticed that 'Show Feature Count' ignores changes made in the DB-Manager (add features/delete features). – Lunar Sea Apr 21 '16 at 8:05
  • 3
    layer.dataProvider().forceReload() should do the trick – Matthias Kuhn Apr 26 '16 at 9:09

Your Answer

