Is possible to define a check constraint that will only will be validated for new inserts?
Asked
Active
Viewed 60 times
0
-
I don't know, but wouldn't the effect of such a policy to create the possibility that your tables could end up full of unsatisfied constraints? – Kevin Boone Oct 06 '17 at 10:06
-
The situation behind this idea is, that I have several legacy data that I could not migrate to satisfy the new check constraint. It would also helpful that the constraint will only enforced if update or insert came around and keep peace for existing data. – zeitiger Oct 06 '17 at 11:14
-
OK. I'm afraid I don't know the answer, but I suspect it will be difficult -- how are constraints on new data to be enforced, except by reference to existing data? If the old data itself doesn't always satisfy the constraints, how can it be used to constrain new data? My gut feeling is that you would need to design new constraints, that refer only to existing data that meets those constraints. However, a person with more knowledge of MariaDB may know a way around the problem. – Kevin Boone Oct 06 '17 at 11:34
1 Answers
0
What do you want to do in the CONSTRAINT
?
Perhaps you could do it in a Trigger on INSERT
.

Rick James
- 135,179
- 13
- 127
- 222