3

I want to delete a column from Attribute table but the function "Delete columns" isn't highlighted. (When I am adding new layers I use New SpatiaLite layer, not Shapefile layer).

So I have installed the plugin Table Manager but when I delete a column using this Table Manager the function "Save" isn't highlighted. Only "Save as" is possible. Is there any advise how I could delete a column?

6

As of QGIS 2.18, SpatiaLite layers have the "Delete Attributes" capability. (Check in Layer Properties | Metadata)


Previously:

It is not possible to directly delete a column in Sqlite and thus in SpatiaLite: http://www.sqlite.org/faq.html#q11. Therefore QGIS cannot offer this functionality. The alternative is to recreate the table.

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT; 
  • 1
    Spatialite-gui has a special tool for that in the right click menu. It may be easier to use and should keep spatial index and constraints untouched. – user30184 Feb 28 '15 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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