Re: Mistakes between an example and its description

From: Martín Marqués <martin(at)2ndquadrant(dot)com>
To: Eugene Wang <eugenewangfw(at)gmail(dot)com>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org, PG Doc comments form <noreply(at)postgresql(dot)org>
Subject: Re: Mistakes between an example and its description
Date: 2018-05-10 19:16:43
Message-ID: CAPdiE1zARLreHEowYuG8Gk5-Eph-tq1v09SomLofr1FGNQ0c6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

2018-05-10 16:04 GMT-03:00 Eugene Wang <eugenewangfw(at)gmail(dot)com>:
> Unique Constraint and Unique Index should be the same in this single-column
> case, right?

The unique index is what enforces the uniqueness of the field with a
UNIQUE constraint, but a unique index is not necessarily a constraint.

For example, you can use a unique index to create a primary key
constraint with the USING clause, but you can't use the UNIQUE index
created by a UNIQUE CONSTRAINT for this action.

> Because, according to CONSTRAINT page in Postgres Documentation, Unique
> Constraint on single column is realized as Unique B-TREE index.
>
> I have just realized that it is still a btree index, but I think this
> example is not exactly a regular btree example. At least I will put the
> example as: CREATE INDEX title_idx ON films USING BTREE(title);

Yes, I agree on dropping the UNIQUE, just like Alvaro. There's another
example which creates a UNIQUE index later in the doc, and not the
best choice for a first example.

Regards,

--
Martín Marqués http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2018-05-10 19:39:16 Re: Mistakes between an example and its description
Previous Message Alvaro Herrera 2018-05-10 19:09:54 Re: Mistakes between an example and its description