Pregunta

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?

¿Fue útil?

Solución

It's possible with a partial unique index:

create unique index uidx on tablename(force_display) where force_display='Y';
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top