gpt4 book ai didi

Android SQLite 列 int 可以 float 吗?

转载 作者:搜寻专家 更新时间:2023-11-01 08:13:11 24 4
gpt4 key购买 nike

我在 Android 市场上有一个应用程序,用户数据存储在 SQLite 中。我创建了一个包含一列整数的数据库表。我现在想在那里存放花车。我怎样才能做到这一点?当我尝试插入 float 时,我的应用程序似乎抛出异常。

最佳答案

作为 SQlite doesn't implement完全支持 ALTER TABLE(仅重命名表和添加列),您必须:

  • 使用新的列格式创建一个临时表,即 float
  • 将原始表中的数据复制到临时表中(整数将“扩大”为 float ,此处不会丢失数据),例如INSERT INTO tmp SELECT * FROM orig
  • 删除原来的表
  • 将临时表重命名为原始表

关于Android SQLite 列 int 可以 float 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7616376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com