gpt4 book ai didi

android - 我们如何删除sqlite中的外键?

转载 作者:IT王子 更新时间:2023-10-29 06:31:11 29 4
gpt4 key购买 nike

我正在使用 SQLite 数据库。我有一个表,其中包含 2 个其他表的主键作为外键;我想删除其中一个。这是表格的代码:

protected static final String Item_places=(" CREATE TABLE " 
+ Item_place + "("
+ place_id + " INTEGER ,"
+ Item_id + " INTEGER ,"
+ "FOREIGN KEY("+place_id+ ") REFERENCES " + PlaceTable + "("+ PlaceID+ " ) ON DELETE CASCADE"
+ "FOREIGN KEY("+Item_id+ ") REFERENCES "+ contentTable+ "("+contentID+"));");

最佳答案

您需要一个 ALTER TABLE DROP CONSTRAINT 命令,但是 SQLite doesn't support this , 请参阅 How do I DROP a constraint from a sqlite (3.6.21) table?寻求解决方法。

关于android - 我们如何删除sqlite中的外键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7224183/

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