gpt4 book ai didi

sql - 如果值不存在,则SQLite插入值

转载 作者:行者123 更新时间:2023-12-03 18:58:40 24 4
gpt4 key购买 nike

插入值时如何避免在SQLite中添加重复条目?

现在,当我插入时,它正在添加重复项。

最佳答案

您需要在表的某处添加唯一索引,才能在其中插入行:

create unique index mytable_id on mytable (id)


现在,如果您尝试将具有相同ID的两行添加到mytable,sqlite将引发错误。

关于sql - 如果值不存在,则SQLite插入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14999848/

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