日期:2014-05-16 浏览次数:20407 次
mysql>INSERT INTO users SET email="foobar@example.com", username="foobar", password="secret"; ERROR 1364 (HY000): Field 'tags' doesn't have a default value
mysql> desc users; +----------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | username | varchar(32) | NO | UNI | NULL | | | password | varchar(32) | NO | | NULL | | | email | varchar(256) | YES | UNI | NULL | | | tags | varchar(255) | NO | MUL | NULL | | +----------------+---------------------+------+-----+---------+----------------+ 50 rows in set (0.01 sec)
# Set the SQL mode to strict sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
SELECT @@GLOBAL.sql_mode; SELECT @@SESSION.sql_mode;
mysql> SET sql_mode = ''; mysql> SELECT NOT 1 BETWEEN -5 AND 5; -> 0 mysql> SET sql_mode = 'HIGH_NOT_PRECEDENCE'; mysql> SELECT NOT 1 BETWEEN -5 AND 5; -> 1