Re: data integrity and inserts
| От | Bruno Wolff III |
|---|---|
| Тема | Re: data integrity and inserts |
| Дата | |
| Msg-id | 20041201205955.GA2831@wolff.to обсуждение исходный текст |
| Ответ на | Re: data integrity and inserts (Scott Frankel <leknarf@pacbell.net>) |
| Список | pgsql-general |
On Wed, Dec 01, 2004 at 10:48:40 -0800, Scott Frankel <leknarf@pacbell.net> wrote: > > 1. > CREATE TABLE names (the_id SERIAL PRIMARY KEY, the_name text); > CREATE UNIQUE INDEX uidx_thename ON names(the_name); > > vs. > > 2. > CREATE TABLE names (the_id SERIAL PRIMARY KEY, the_name text UNIQUE); > > > Is the UNIQUE constraint in the second solution merely short-hand for > the explicit > index declaration of the first solution? Or is there a functional > difference between > them that I should choose between? Currently the only way to enforce a UNIQUE constraint is by using an index. So there isn't really much difference between the two. However, I think using the UNIQUE constraint provides better meaning than using an index for people who might look at your definitions later.
В списке pgsql-general по дате отправления: