0

Is it possible to alter a table so that the row as a whole (excluding the IDENTIFIER (ID) ) can only be inserted once in the database? For example; you have a Start and End timestamp for an Employee, and you want other employees to be able to have the same Start and End value, but you don't want the same Employee to be able to inserted twice the same Start and End value?

2
  • I removed the inconsistent database tags. Tag only with the database you are really using. May 27, 2020 at 20:09
  • 1
    Perhaps you also want to reject overlapping periods for an employee?
    – jarlh
    May 27, 2020 at 20:12

1 Answer 1

1

You can define a unique constraint or index for the rest of the rowsin the column:

alter table t add constraint t_unique_all unique (employee, start, end)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.