Subject: Reg. Postgres Unique contraint

From: Sajjad Abid <[email-masked]>
Date: Wed, 27 Nov 2024 09:44:36 +0530

A column is character varying(50), also on this column a unique
constraint is defined, but I found some duplicate values in this column for
some records
  user_name character varying(50)
  CONSTRAINT  user_name_unq   UNIQUE ( user_name )

Kindly help me to resolve this issue.

-- 

*Thanks & Regards, Sajjad Abid*

---

From: Diomedes Dominguez <[email-masked]>
Date: Wed, 27 Nov 2024 00:18:55 -0400

Which version of Postgres are you using?

---

From: Sajjad Abid <[email-masked]>
Date: Wed, 27 Nov 2024 09:57:48 +0530

Version of Postgres is 12.9

--

---

From: Burcin Yazici <[email-masked]>
Date: Wed, 27 Nov 2024 09:22:36 +0300

hi,

make sure that the values are really duplicated first..

- check  the collation of column.

- check accent chars exist.

- check lowercase, uppercase

- check white space, tabs etc.

burcin

On 27 Nov 2024, at 07:28, Sajjad Abid <[email-masked]> wrote:

On Wed, Nov 27, 2024 at 9:49 AM Diomedes Dominguez <[email-masked]> wrote:

El mié, 27 de nov de 2024, 00:14, Sajjad Abid <[email-masked]> escribió:

A column is character varying(50), also on this column a unique constraint is defined, but I found some duplicate values in this column for some records

CONSTRAINT

user_name_unq   UNIQUE (

user_name )

--

Thanks & Regards,

Sajjad Abid

--

Thanks & Regards,

Sajjad Abid

---

From: Vitalii Tymchyshyn <[email-masked]>
Date: Wed, 27 Nov 2024 17:13:03 +1000

We saw it when OS image changed resulting in collation library change, so
index lookups started to fail and reindex was needed to fix it.

---

From: <[email-masked]>
Date: Fri, 27 Dec 2024 12:54:52 +0100

Hi,

Does the following query return something:

Select user_name, count(*) from your_table group by user_name having count(*) > 1

Best regards

Michel SALAIS

De : Sajjad Abid <[email-masked]> 
Envoyé : mercredi 27 novembre 2024 05:28
À : Diomedes Dominguez <[email-masked]>
Cc : [email-masked]
Objet : Re: Reg. Postgres Unique contraint

On Wed, Nov 27, 2024 at 9:49 AM Diomedes Dominguez <[email-masked] <mailto:[email-masked]> > wrote:

El mié, 27 de nov de 2024, 00:14, Sajjad Abid <[email-masked] <mailto:[email-masked]> > escribió:

-- 

Thanks & Regards, 

Sajjad Abid

-- 

Thanks & Regards, 

Sajjad Abid

---

From: [email-masked]
Date: Fri, 27 Dec 2024 13:57:59 +0100

Am 27.11.24 um 05:14 schrieb Sajjad Abid:
> constraint is defined, but I found some duplicate values in this
> column for some records user_name character varying(50) CONSTRAINT
> user_name_unq   UNIQUE ( user_name )

Most likely a locale/encoding problem.

See: https://wiki.postgresql.org/wiki/Locale_data_changes