MySQL has an UNSIGNED qualifier for integer types.
Negative values will be clamped to zero, but generate a warning:
mysql> create table test ( id int(5) unsigned not null ); Query OK, 0 rows affected (0.05 sec) mysql> insert into test values (-1), (5), (10); Query OK, 3 rows affected, 1 warning (0.01 sec) Records: 3 Duplicates: 0 Warnings: 1 mysql> select * from test; +----+ | id | +----+ | 0 | | 5 | | 10 | +----+ 3 rows in set (0.01 sec)
source share