22

When is the option to delete field in an attribute table enabled in QGIS?

I'm in editing mode and still am not able to delete a field.

0

8 Answers 8

17

Recent versions of QGIS support deleting Shapefile fields from the attribute table.

Enable editing and then you can edit the shapefile attribute table and multi-delete the columns you do not need.

enter image description here

0
9

In QGIS 3.x there is also a button to delete attributes in the properties menu. First toggle editing (right click on a layer -> toggle editing) and go to the properties menu (right click -> properties or just double click). Go to the source fields tab, select the attributes you want to delete and click the button on top.Delete field

6

That button is only avaliable for a PostGIS layer. You can delete table columns via the "table manager" plugin.

0
3

The "Table Manager" plugin is obsolete. It comes with a warning that it is discontinued and suggests that you use the Refactor Fields processing algorithm instead. This can work. However, another method is to save the layer with a new name, deselect the fields you wish to export, and then delete the previous version that has the fields you wanted removed after the new layer is created.Save As Screen Shot highlighting where to Deselect Fields

3

In QGIS 3.20.0 or newer, the Refactor fields tool can be used to change field types or delete fields. It's found in the Vector table section of the Processing toolbox.

0

After looking around many files I found that some field definitions -- especially fields defined through an expression such as "$length" -- appear to be stored only in the *.qgs file, which (at least for QGIS 2.18.13) is an XML file, which means it is a text file that can be edited using simple text editors. The name of the QGIS layer is stored in the <layername>...</layername> element. Look for the layer of interest. The expression fields are listed in the <expressionfields>...</expressionfields> element. For example

<expressionfields>
  <field typeName="FLOAT" precision="0" expression="$length/1000" length="0" type="6" comment="" name="km"/>
</expressionfields>

for a field named "km" whose value is calculated as $length/1000. Delete the <field>...</field> element that you don't want anymore (when the *.qgs file is not in use). Be sure to make a copy of the *.qgs file first, in case things go wrong.

0

Try exporting the layer and only include the attributes you need. I see that QGIS Attribute editor gets quite slow with large tables with many attributes.

-2

You should look into RT SQL Layer plugin or Fast SQL plugin for QGIS.

A SQL console in QGIS

Not the answer you're looking for? Browse other questions tagged or ask your own question.