在Room中使用现有的VARCHAR列 [英] Using an existing VARCHAR column with Room

查看:251
本文介绍了在Room中使用现有的VARCHAR列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将现有的数据库用于Android Room. 但是,我的表之一有一个VARCHAR列.

I'm trying to use my existing db with the Android Room. However, one of my tables have a VARCHAR column.

似乎Room仅支持TEXT,而不支持VARCHAR.而且sqlite不允许修改列类型.

It seems Room only supports TEXT and not VARCHAR. And sqlite doesn't let to modify column type.

那么,有什么方法可以将Roomng表与存在表一起使用?还是应该将整个表复制到一个新表中,将VARCHAR替换为TEXT?

So, is there any way to use the existng table with VARCHAR fields in the Room? Or should I copy the whole table to a new one replacing VARCHAR to TEXT?

推荐答案

是的,您肯定需要将整个表复制到一个新表中,并用TEXT替换VARCHAR.唯一的方法是在室外"房间.使用通常的SQLite.

Yes, you will definitely need to copy the whole table to a new one and replace VARCHAR by TEXT. And the only way to do it is "outside" room. With the usual SQLite.

这篇关于在Room中使用现有的VARCHAR列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆