为什么视频里的1111可以计算出数值,我的却不行。
这个是什么原因? 为什么呀?为什么我插入的计算不出来。 这是怎么转换的? out of range了啊 本帖最后由 Shell_HAT 于 2015-08-28 22:23 编辑
5.6.5之前的sql_mode默认值是''
5.6.6之后的sql_mode默认值是'NO_ENGINE_SUBSTITUTION'
mysql> create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint);
Query OK, 0 rows affected (0.02 sec)
mysql> desc t1;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| a | tinyint(4) | YES| | NULL | |
| b | smallint(6)| YES| | NULL | |
| c | mediumint(9) | YES| | NULL | |
| d | int(11) | YES| | NULL | |
| e | bigint(20) | YES| | NULL | |
+-------+--------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mysql> insert into t1 values ('11111111111111111111','11111111111111111111','11111111111111111111','11111111111111111111','11111111111111111111');
ERROR 1264 (22003): Out of range value for column 'a' at row 1
mysql> show variables like 'sql_mode';
+---------------+--------------------------------------------+
| Variable_name | Value |
+---------------+--------------------------------------------+
| sql_mode | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------+
1 row in set (0.01 sec)
mysql> set sql_mode = '';
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'sql_mode';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_mode | |
+---------------+-------+
1 row in set (0.01 sec)
mysql> insert into t1 values ('11111111111111111111','11111111111111111111','11111111111111111111','11111111111111111111','11111111111111111111');
Query OK, 1 row affected, 5 warnings (0.01 sec)
mysql> select * from t1;
+------+-------+---------+------------+---------------------+
| a | b | c | d | e |
+------+-------+---------+------------+---------------------+
|127 | 32767 | 8388607 | 2147483647 | 9223372036854775807 |
+------+-------+---------+------------+---------------------+
1 row in set (0.00 sec)
页:
[1]