I accidentally tried to insert ‘asdf’ into an integer column. It worked (put 0 in the column), and gave this warning:
Incorrect integer value: ‘asdf’ for
column ‘Author’ at row 1
How can I cause similar insertions to fail instead of merely issuing a warning?
As of MySQL 5.0, there is an option
sql_modeyou can set, either in themy.cnfor during startup (--sql-mode='<option>') or during a running session. When you set it tomysql will not issue a warning and insert the wrong value anyways, but it will refuse your statement with an error.
See also in the manual
Example: