2018-05-10 16:04 GMT-03:00 Eugene Wang <eugenewan...@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