6

I want to implement delete column in Android's SQLite. I want to make table copy without desired column, than delete former tablet and set name at new_one as a former name. I have made table to table copy, but now I have it as a 1:1 copy. How to change columns when copyiing?

Goal is to have method deleteColumn(int indexOfColumn);

Thanks

Waypoint
  • 17,283
  • 39
  • 116
  • 170
  • This answer gives a very good explanation of how this can be achieved. http://stackoverflow.com/questions/3424156/upgrade-sqlite-database-from-one-version-to-another/3424444#3424444 – Graham Borland Nov 03 '11 at 11:21

1 Answers1

15

drop your new table first,then create a new table directly with desired columns as follows:

create table new_table as select column1,column2,....from old_table;

Here select those columns that you want to see in new table.Then drop old table and rename new table to old table's name.Hope it will work.

Android Killer
  • 18,174
  • 13
  • 67
  • 90