how to set a column as unique indexer on Sqlite

I have 3 columns (_id, column1, column2) _id column has been set as autoincrement

In database there are some duplicate records, so I want to prevent duplicate records with setting column1 as unique indexer. How do I set a column as unique indexer on sqlite? Or how do I prevent duplicate records?

Answers


No magic, just SQL:

create table yourtablename (_id  integer primary key autoincrement, column1 text not null unique, column2 text);

_id will not be duplicate in any way because it is primary key, column1 neither because it is unique.


Need Your Help

How to use sysfs inside kernel module?

linux linux-kernel kernel-module

In userspace I can just echo noop > /sys/block/sda/queue/scheduler.

Techniques for understanding Android Methods

java android oop

I have just finished up my first book on Java training and I think I am getting closer to understanding. I am currently looking for some good resources to improve my java understanding.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.