Domanda

I have a table with a column called force_display. This column is 1 character long and takes either a Y or N. I want to be able to enter as many N as I want but have a constraint where a Y can only exists once in that table. Does anyone know how to achieve this or is it not possible?

È stato utile?

Soluzione

It's possible with a partial unique index:

create unique index uidx on tablename(force_display) where force_display='Y';
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top