MySQLint(4)类型的值范围是多少呢?
mysql> create table t1 (a int(4));
Query OK, 0 rows affected (0.14 c)
mysql> inrt into t1 values(15652);
Query OK, 1 row affected (0.06 c)春联对联大全
mysql> inrt into t1 values(156522);
Query OK, 1 row affected (0.05 c)仙灵女巫
mysql> inrt into t1 values(156********);
ERROR 1264 (22003): Out of range value adjusted for column 'a' at row 1
月季和玫瑰mysql> inrt into t1 values(1565222);
幸福的时刻Query OK, 1 row affected (0.06 c)
三级色带
网络错误651
mysql> inrt into t1 values(15652222);
Query OK, 1 row affected (0.08 c)
mysql> inrt into t1 values(156522222);
Query OK, 1 row affected (0.05 c)
mysql> inrt into t1 values(1565222222);
Query OK, 1 row affected (0.03 c)
mysql> inrt into t1 values(1565222222)2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL rver version for the right syntax to u near '2' at
line 1
mysql>
为什么int(4)类型的字段可以插⼊9位的数字呢?
int(n)中不论n指定为多少,范围都⼀样-2~31~2^31-1,都能插⼊9位数字。n只是⽤来控制显⽰⽽已,如果为低脂食物
int(4),插⼊⼀个1,显⽰时也会⽤空格补齐到4个字节
请问所有mysql中的数据类型中的(n)都是表⽰显⽰位数吗?
并⾮如此,NUMERIC(4)就限定了取值范围,超过4位就不允许写⼊了。因此如果你想限定数字的取值范
围,最好是⽤NUMERIC来定义。
>初中电路图