0

I'm working on MySQL Server 5.6.14.0, And Unable to find such kind of constraint which enable us to insert a limited values in a column or field. For Example, I want to declare a constraint in a columns which accepts only Value from 0 to 10 or A to Z, not more than that.

  • http://stackoverflow.com/questions/9249695/limit-the-value-of-a-mysql-datatype-to-a-specific-range-preferably-not-enum – Mihai Oct 22 '13 at 18:53

2 Answers2

0

Just create a table with a column of allowed values and reference that in a foreign key.

Mihai
  • 26,325
  • 7
  • 66
  • 81
0

You can create insert/update trigger, which will check values inserted and throw error, here is example of throwing error: How to raise an error within a MySQL function

Community
  • 1
  • 1
Iłya Bursov
  • 23,342
  • 4
  • 33
  • 57