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.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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.
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.
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.
You should look into RT SQL Layer plugin or Fast SQL plugin for QGIS.