I am using MYSQL database for my application. Is it possible to give condition in each columns to accept values within the range.
For example, Lets say I am having column 'age' of integer type in a table. During insert statement this column should accept value only from 0-100. i.e it should not accept negative values or greater than 100. If so, it should return me an error.
How could I setup this condition in MYSQL database?
Is there any alternative option to do it?
Thanks in advance.
MySQL doesn't support CHECKs, you must do it in your application or use a Trigger or Stored Procedure to check for wrong data:
The CHECK clause is parsed but ignored by all storage engines.