Case insensitive unique constraint
Case insensitive unique constraint
От:
Michael Rowan <michael.rowan3@gmail.com>
Дата:
HI
I would like to do this:
ALTER TABLE a ADD CONSTRAINT a_unique UNIQUE lower(name)
This fails, syntax error near "lower"
This succeeds:
ALTER TABLE a ADD CONSTRAINT a_unique UNIQUE name
Can I get what I want, and if so, how? Many thanks.
Mike
Re: Case insensitive unique constraint
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Michael Rowan writes: > I would like to do this: > ALTER TABLE a ADD CONSTRAINT a_unique UNIQUE lower(name) You can't get to that through CONSTRAINT syntax, but you can just create a unique index directly: CREATE UNIQUE INDEX a_unique ON a (lower(name)) regards, tom lane