我一直在和我的 friend 一起为我的学校项目开发 android 应用程序,他做了数据库部分,我们使用 SQLite,我想使用他创建的数据库方案,但是表已经定义了,我怎么能不知何故,重命名表并在其中插入我自己的数据而不更改方案?我们都使用相同的项目文件夹,所以我现在有点卡住了,谢谢。
最佳答案
通过使用 Alter Table :
ALTER TABLE oldTableName RENAME TO newTableName
很明显,将 oldTableName
和 newTableName
替换为您选择的任何内容。然后您可以使用新名称INSERT INTO
您的表。请记住,对这个旧表的任何引用也需要更新。
如果您使用任何触发器,也要小心:
Important Note: The
'ALTER TABLE ... RENAME TO ...'
command does not update action statements within triggers or SELECT statements within views. If the table being renamed is referenced from within triggers or views, then those triggers and views must be dropped and recreated separately by the application.
关于java - 如何在 SQLite android studio 中替换表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45464196/