I have a table in Postgres which currently has a NOT NULL
constraint on it's email
column. This table also has a phone
column which is optional. I would like the system to accept some records without email
but only if these have phone
as NOT NULL
. In other words, I need a NOT NULL
database constraint such that CREATE
or UPDATE
queries succeed without any errors if either or both of email
or phone
fields are present.
Extending the above further, is it possible in Postgres, to specify a set of column names, one or more of which should be NOT NULL
for the record to be successfully updated or created?