Re: Mistakes between an example and its description - Mailing list pgsql-docs

From Martín Marqués
Subject Re: Mistakes between an example and its description
Date
Msg-id CAPdiE1zARLreHEowYuG8Gk5-Eph-tq1v09SomLofr1FGNQ0c6A@mail.gmail.com
Whole thread Raw
In response to Re: Mistakes between an example and its description  (Eugene Wang <eugenewangfw@gmail.com>)
Responses Re: Mistakes between an example and its description  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-docs
2018-05-10 16:04 GMT-03:00 Eugene Wang <eugenewangfw@gmail.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


pgsql-docs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Mistakes between an example and its description
Next
From: "David G. Johnston"
Date:
Subject: Re: Mistakes between an example and its description