문제

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?

도움이 되었습니까?

해결책

It's possible with a partial unique index:

create unique index uidx on tablename(force_display) where force_display='Y';
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top