SQL table constraint limit number of same domain < 5 I have a table "Applies" with one of its attribute "applicantNum".

Is there a way to set a constraint to check the value inside a domain has less than 5 repeated value?

E.g.

insert into applies(applicantNum) values ('s12345');&lt;-- 1st insertion
insert into applies(applicantNum) values ('s12345');&lt;-- 2nd insertion
insert into applies(applicantNum) values ('s12345');&lt;-- 3rd insertion
insert into applies(applicantNum) values ('s12345');&lt;-- 4th insertion
insert into applies(applicantNum) values ('s12345');&lt;-- 5th insertion
insert into applies(applicantNum) values ('s12345'); &lt;-- error
You need to normalize the database, or you'll have to use a trigger. There is a method of doing what you want, it can be done with F671, “Subqueries in CHECK constraints” however Oracle doesn't implement them. For that, you'll have to turn to everyone's favorite database, Microsoft Access.

To normalize create a table like this with a check constraint on the amount of attempts, then increase the amount of attempts. The CHECK constraint will resist incrementing past 5.

CREATE TABLE applicant (
  applicantNum     int        PRIMARY KEY,
  applicantentries smallint   CHECK ( applicantentries &lt; 5 )
);