Re: Unique index - Mailing list pgsql-admin

From Erik Wienhold
Subject Re: Unique index
Date
Msg-id g5p6dubjfljp4rnsabcfdiaswcs27xgppyn2gsr2f7mrmlpjze@3jfl43hbbn6p
Whole thread Raw
In response to Unique index  (Rajesh Kumar <rajeshkumar.dba09@gmail.com>)
List pgsql-admin
On 2023-09-20 19:16 +0530, Rajesh Kumar wrote:
> Why unique index is used over unique constraints?

Is the question why someone might want to use a unique index instead of
a unique constraint?  The index can be functional, e.g.

    CREATE TABLE account (username text NOT NULL);
    CREATE UNIQUE INDEX account_lower_username_idx ON account (lower(username));

will make the username unique and case-insensitive (depending on the
collation and locale).

-- 
Erik



pgsql-admin by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Unique index
Next
From: "David G. Johnston"
Date:
Subject: Re: Unique index