"flakpit" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
> is it legal sql syntax to allow more than one constraint field in
> table creation? I need at least these four below to guarantee that
> duplicate items do make it into the database but not on the same day.
>
> item TEXT CONSTRAINT item UNIQUE
> units TEXT CONSTRAINT units UNIQUE
> shop TEXT CONSTRAINT shop UNIQUE
> date TEXT CONSTRAINT date UNIQUE
It is possible to have multiple constraints, but declaring each field
unique individually won't do what you want. Consider:
create table t(a unique, b unique);
insert into t values('a', 'b'); -- ok
insert into t values('a', 'c'); -- fails: column a is not unique
insert into t values('z', 'b'); -- fails: column b is not unique
create table t(a, b, unique(a, b));
insert into t values('a', 'b'); -- ok
insert into t values('a', 'c'); -- ok
insert into t values('z', 'b'); -- ok
insert into t values('z', 'b'); -- fails: this pair already exists
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users