int(1)和int(10)在mysql占的大小都是4字节么
int(1)和int(10)占用字节数都是4个字节。
对 都是4字节
int1和int10的区别在于如果表定义加上zerofill后再客户端显示长度不同
mysql> create table test5(a int(10) zerofill);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test5 values(1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from test5;
+------------+
| a |
+------------+
| 0000000001 |
+------------+
1 row in set (0.00 sec)
mysql> create table test6(a int(20) zerofill);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test6 values(1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from test6;
+----------------------+
| a |
+----------------------+
| 00000000000000000001 |
+----------------------+
1 row in set (0.00 sec)
mysql>