ngageoint / geopackage-android

GeoPackage Android Library
http://ngageoint.github.io/geopackage-android
MIT License
94 stars 32 forks source link

Remove table column #52

Closed osedok closed 5 years ago

osedok commented 5 years ago

Dear Brian (@bosborn), I know there is no direct method to ALTER the table and remove the field in SQLite, but just as a curiosity - do you think of supporting this kind of operation as part of API?

At the moment I have kind of the workaround (copy table, delete, create, insert from copy) semi working in test but If you could say what you think about this that would be great.

Kind Regards, Andrzej

bosborn commented 5 years ago

You can execute raw SQL within the GeoPackage

SQLite only supports a subset of common alter statements. Dropping a column requires a new table (see the 12 steps under Making Other Kinds Of Table Schema Changes).

osedok commented 5 years ago

@bosborn - Yes, that is what I am doing right now. Thanks.

Regards, Andrzej

bosborn commented 5 years ago

I'm not opposed to trying to support this full set of operations as an API shortcut. We can leave this open to track the request.

osedok commented 5 years ago

Thanks, creating a method on the FeatureTable object would be fantastic. Thanks for considering it. The good thing would be also the option to keep all existing nga indices and metadata for the feature layer to speed up the process for larger layers.

sunshine0576 commented 5 years ago

SQLite 不支持删除字段,只能通过下面的方式实现 create table temp as select field1, field2, ..., from record drop table record;
alter table temp rename to record;

bosborn commented 5 years ago

I have something in progress and looking promising here.

bosborn commented 5 years ago

Released 3.3.0. AlterTable does most of the work. You can remove user table columns here.