Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 3 列(_id、column1、column2)_id 列已设置为自动增量
在数据库中有一些重复的记录,所以我想通过将 column1 设置为唯一索引器来防止重复记录。如何在 sqlite 上将列设置为唯一索引器?或者如何防止重复记录?
没有魔法,只有 SQL:
create table yourtablename (_id integer primary key autoincrement, column1 text not null unique, column2 text);
_id 不会以任何方式重复,因为它是主键,column1 也不会因为它是唯一的。