On 1 Mar 2017, at 5:00pm, Deon Brewis <de...@outlook.com> wrote:

> Is there way to add non-unique columns in a unique index?

I don’t know of anything that operates in that way.

> If not, is there a way to efficiently implement a UNIQUE constraint in a 
> different way? (Trigger maybe?)

Not efficiently.  You could make a non-UNIQUE index which has the columns you 
want UNIQUE at the beginning.  Then you could include a check for uniqueness in 
your own code.  This would probably tempt SQLite to use that index when 
checking uniqueness.  But this strikes me as less efficient than just letting 
SQLite do its own thing.

But it would be far more efficient just to create two indexes, one for the 
UNIQUE and one for coverage.  Or just create the UNIQUE index and let SQLite 
get the other columns itself.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to