On 16 Apr 2014, at 4:02pm, Christoph P.U. Kukulies <k...@kukulies.org> wrote:

> Am 16.04.2014 15:57, schrieb Richard Hipp:
>> 
>> CREATE UNIQUE INDEX version_idx1 ON version(major,minor,date);
> 
> Though this seems to work, could I achieve this also by a table constraint, 
> like UNIQUE(major,minor,date) ?

Yes.  In the CREATE TABLE command, after your list of columns but inside the 
same set of brackets, add

, CONSTRAINT con_1 UNIQUE (major,minor,date) ON CONFLICT IGNORE

> Can I apply that a posteriori to the table? I tried SQLite database browser 
> 2.0.b1 but can't figure out how.

No.  There's no way to add it once you have defined the table.  Which is 
probably why Dr Hipp suggested doing it as an INDEX.

If you really want to do it in the TABLE definition, use the SQLite shell tool 
to '.dump' the table as a set of SQL commands, edit the dump file to add that 
constraint, then use the SQLite tool to '.read' the SQL command file.

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

Reply via email to