sqlite replace失效的教训,sqlitereplace失效
20140925 通宵加班解决 android版本企信 增量通讯录会有记录重复的问题,主要原因在于,旧版的创建表的脚本没有指定primary key,而在升级脚本中 使用 ALTER TABLE [testpri] ADD PRIMARY KEY id 来创建主键,实际上主键没有创建成功。而增量的代码中间,更新数据使用了 sqlite的 replace 来执行。新版建表脚本已经含了主键创建的内容,所以不会有问题;而sqlite的table一旦创建,就无法创建主键了 ,只能通过临时表来解决。replace根据主键确定被替换的是哪一条记录
,以下为原文:You can't modify SQLite tables in any significant way after they have been created. The accepted suggested solution is to create a new table with the correct requirements and copy your data into it, then drop the old table.
here is the official documentation about this: http://sqlite.org/faq.html#q11
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。