Re: Unique index

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Rajesh Kumar <rajeshkumar(dot)dba09(at)gmail(dot)com>
Cc: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Unique index
Date: 2023-09-20 16:45:34
Message-ID: g5p6dubjfljp4rnsabcfdiaswcs27xgppyn2gsr2f7mrmlpjze@3jfl43hbbn6p
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2023-09-20 17:08:12 Re: Unique index
Previous Message Laurenz Albe 2023-09-20 14:14:52 Re: Unique index