Reputation: 573
I want to create a table of emails emails
where all values in the "email" column must be unique except one for a "[email protected]" placeholder. Example:
I see in postgres documentation that it's straightforward to allow null
values to be non-duplicative, but is there a way to do this with another value?
Upvotes: 1
Views: 49
Reputation: 1270773
You can create a filtered unique index:
create unique index unq_emails_email on (email)
where email <> '[email protected]';
Upvotes: 2