[GIS] Changing attribute length of existing field afterwards

lengthqgistable

I already have about 100 values in a field in QGIS. I set it to 50 characters because I was thinking that would be enough. But that was wrong. I need more space in the column. But there is no way to change it. In the usual editor you only can remove or add a new field.

And in the "advanced" table manager you can change the position and rename it. But nowhere where I edit the length of a field.

The only thing I could do is creating a new field with more space. Then import the data somehow. But does that work somehow? Or is there a way to edit the text length afterwards. I'm also interested in hacks.

And yes I really need that. There is no way to get the string any shorter. I think 100 chars are fine.


Now it came to mind the following. Could maybe someone tell if that is working before I try that. So First of all I would create a new field with 100 chars column. Than select all old features and CTRL-X them and CTRL-V into the new shape.

Will that work out?

Best Answer

The field calculator lets you easily create new fields and insert all values of an existing field in one step.

With the table manager plugin, you can delete the old field, and rename the new one to the name of the deleted field. This will work for shapefiles, but not for spatialite and postgis database tables. You have to use SQL statements for those.

Related Question