As far as I know, there is no such constraint at the database level. The common approach is to enforce the constraint at the application level by checking before inserting. Alternatively, a trigger in the database can achieve the same effect, but this method is rarely used. Generally, the constraint is enforced at the application level.
Application level refers to enforcing the constraint within your business logic code.
(My English is poor, this was translated using a translation tool, so please forgive me if the sentences are awkward.)