我如何从房间数据库android中的表中删除列。我一直尝试删除和删除的方式。
此代码也不起作用:-
static final Migration MIGRATION_3_4 = new Migration(3, 4)
{
@Override
public void migrate(SupportSQLiteDatabase database)
{
database.execSQL("CREATE TABLE users_new (userid TEXT, username TEXT, last_update INTEGER, PRIMARY KEY(userid))");
// Copy the data
database.execSQL("INSERT INTO users_new (userid, username, last_update) SELECT userid, username, last_update FROM users");
// Remove the old table
database.execSQL("DROP TABLE users");
// Change the table name to the correct one
database.execSQL("ALTER TABLE users_new RENAME TO users");
}
};
答案 0 :(得分:0)
Android ROOM基于SQL Lite,不允许删除数据库表列。相反,您必须: