How to change field length in QGIS

Here is a solution which surprised me that it worked!!!

Warning: first make a backup.This is an experiment though it worked for me just now..

open the .dbf of the particular shapefile using OpenOffice Calc application. Change value from 80 to whatever value you want. Please see the image below. Surprising thing is these field definitions were not visible in Excel..Advantage of being Open!!

enter image description here


To my knowledge, you cannot alter the length of shapefile fields in QGIS. Recommend creating a new field:

  • Open attribute table
  • Toggle editing on
  • Select 'New Column' and set
    type to text, and choose the desired width

If there is already data in the old field, use field calculator to populate the new field:

  • Select 'Field Calculator'
  • Tick 'Update existing field' and choose the new field
  • Double-click the old field name under 'Fields'
  • Hit 'OK' and don't forget to save your edits.

I've just done this in Excel. open the dbf in Excel, right click the column header you want to change and select Column Width. Change to the length you need, then save as a dbf. Seemed to work OK for me.

Tags:

Shapefile

Qgis