Reputation: 60341
I'm thinking of ADD CONSTRAINT to my db table as per example from http://www.w3schools.com/sql/sql_unique.asp
ALTER TABLE Persons ADD CONSTRAINT uc_PersonID UNIQUE (P_Id,LastName)
However, discover from https://www.sqlite.org/omitted.html, ADD CONSTRAINT is not supported by SQLite. What's the option I have (fyi, I'm developing in Android, and only have SQLite).
Upvotes: 0
Views: 193
Reputation: 1271151
Instead of a unique constraint, just add a unique index:
CREATE UNIQUE INDEX unq_persons_pid_lastname ON PERSONS(P_Id, LastName);
It is curious that you would have a table called Persons
and that P_Id
would not already be unique in the table (by being a primary key).
Upvotes: 1