Bug #62277 | data types defaults | ||
---|---|---|---|
Submitted: | 28 Aug 2011 13:26 | Modified: | 31 Aug 2011 4:42 |
Reporter: | Susanne Ebrecht | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 5.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[28 Aug 2011 13:26]
Susanne Ebrecht
[28 Aug 2011 18:47]
Valeriy Kravchuk
Case 1 is explained at the beginning of the same manual page: "If a column definition includes no explicit DEFAULT value, MySQL determines the default value as follows: If the column can take NULL as a value, the column is defined with an explicit DEFAULT NULL clause."
[28 Aug 2011 18:52]
Valeriy Kravchuk
Case 2 should be tested by inserting row without explicit values for columns, in non-strict SQL mode. This is when implicit default 0 should appear. "Implicit" means that it is NOT presented in CREATE TABLE. If you ask me, there is no bug here. But I let you double check.
[30 Aug 2011 19:58]
Susanne Ebrecht
create table t(i integer, n numeric(5,2), d decimal(5,2)); insert into t(i) values(2); select * from t; +------+------+------+ | i | n | d | +------+------+------+ | 2 | NULL | NULL | +------+------+------+ 1 row in set (0.00 sec) Looks like NULL or?
[31 Aug 2011 4:42]
Valeriy Kravchuk
In your table all columns accept NULLs, so NULLs are used when explicit value is not provided. What else one should expect? Implicit defaults are used when column is declared as NOT NULL, has no explicit DEFAULT defined and you insert row without any defined value for the column: mysql> create table ti(i int, d decimal(5.2) NOT NULL); Query OK, 0 rows affected (0.23 sec) mysql> insert into ti(i) values(1); Query OK, 1 row affected, 1 warning (0.03 sec) mysql> show warnings\G *************************** 1. row *************************** Level: Warning Code: 1364 Message: Field 'd' doesn't have a default value 1 row in set (0.00 sec) mysql> select * from ti; +------+---+ | i | d | +------+---+ | 1 | 0 | +------+---+ 1 row in set (0.02 sec) You can see implicit default used above. IMHO documentation is clear enough on this.