mysql> create table foo(title char(10) not null);
Query OK, 0 rows affected (0.06 sec)
mysql> insert into foo(title) values (NULL);
ERROR 1048 (23000): Column 'title' cannot be null
that was expected...
mysql> insert into foo(title) values (NULL),("OH SNAP");Hmm, not quite what I was expecting...error became a warning..
Query OK, 2 rows affected, 1 warning (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 1
mysql> show warnings;
+---------+------+-------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------+
| Warning | 1048 | Column 'title' cannot be null |
+---------+------+-------------------------------+
1 row in set (0.00 sec)
mysql> select * from foo;we get the default empty string inserted for us...how nice
+-----------+
| title
+-----------+
| asdf
|
| OH SNAP
+-----------+
3 rows in set (0.00 sec)
mysql> set sql_mode='TRADITIONAL';woot, stricter now..
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @@session.sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------+
| @@session.sql_mode |
+-------------------------------------------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER |
+-------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> insert into foo(title) values (NULL),("asdf");
ERROR 1048 (23000): Column 'title' cannot be null
A
No comments:
Post a Comment