I need a table which will allow to insert values into a column with values greater than 10. When I tried in net, they suggested to create table in following way.

CREATE TABLE test ( UID int(11) NOT NULL auto_increment, ID int(11) default NULL, CHECK (ID > 10), PRIMARY KEY (UID) );

And when I try to insert an entry with values less than 10, still values are getting inserted.

I can use Before trigger on the table to restrict insertion of values less than 10. But I wanted other approach which satisfies this condition.

I am using MySQL server 5.0.24

Please help me out of this.


According to MySQL doc: "The CHECK clause is parsed but ignored by all storage engines."

  • Thanks for the answer. Is there any other approach to have check on the column other than trigger. – Phanindra Jun 16 '11 at 9:46
  • Not at a the moment. It's the only solution so far. – olefebvre Jun 17 '11 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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