Sqlite Add a column to a table at a specific position (Android)

This is the code that works to add a column.

mDb.execSQL("ALTER TABLE " + table_name + " ADD COLUMN " + column_name + " text"); 

My problem: the column is being created at the last position of the table.

 Column1|Column2|Column3|Column4|Column5|NewAddedColumn6 

eg. Is it possible to add a column between Column3 and Column4 ???

 Column1|Column2|Column3|NewAddedColumn6|Column4|Column5 
+8
android sql mysql sqlite
source share
1 answer

According to the documentation

The syntax ADD COLUMN used to add a new column to an existing table. A new column is always added to the end of the list of existing columns.

Hence the answer to your question: NO

But there is work around.
Read this answer on SO .

Refer to : SQLite: ALTER TABLE: ADD COLUMN

+14
source share

All Articles