Prevent having a zero value in a mysql field

Viewed 3043

I have a table like this:

CREATE TABLE mytable (   
  id int(10) unsigned NOT NULL AUTO_INCREMENT,   
  mynum int(10) unsigned NOT NULL,  
)

The default value for an int is 0 (zero). In my application, 0 is an invalid value for "mynum".

How can I ensure that a 0 is never entered for mynum? I can do the check in my application code, but I wish I didn't have to do that. I want mysql to prevent any insert of value 0 in the mynum field.

Thanks.

1 Answers
Related