Search code examples
mysqlsqlconstraints

MYSQL - How to avoid/block insert date with zero value (0000-00-00)


Is possible create a constraint on MYSQL to avoid date with zero value or null? (0000-00-00)

May be throwing a error.

enter image description here


Solution

  • SET GLOBAL sql_mode = 'NO_ZERO_DATE';

    see: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_no_zero_date