本文介绍了OrmLite - 保存表升级之前的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以从表中数据保存我的模型更改数据库之前?

例如我重命名列,也不会丢失数据。所以,即我要来从C1列的所有数据,我列重命名为C2和所有的数据写回。


解决方案

Sqlite does not support the renaming of columns so this will not work under Android. You can certainly add an additional column however. There is some good documentation on schema changes under Android/ORMLite. See this page:

For example, you can do the following schema updates:

dao.executeRaw(
    "ALTER TABLE `account` ADD COLUMN hasDog BOOLEAN DEFAULT 0;");
dao.updateRaw("UPDATE `account` SET hasDog = 1 WHERE dogCount > 0;");

这篇关于OrmLite - 保存表升级之前的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:31