做渠道的网站有哪些,个人博客网站html模板,下载小程序,购物网站建设市场调查论文存储宽度 是实际存储记录宽度存储宽度默认是写死的#xff0c;就算修改宽度也改变不了#xff0c;改变的是显示宽度有符号和无符号int创建一个 无符号的 int 整数类型mysql create table t3(id int(1) unsigned);Query OK,0 rows affected (0.01sec)mysql desct3;---…存储宽度 是实际存储记录宽度存储宽度默认是写死的就算修改宽度也改变不了改变的是显示宽度有符号和无符号int创建一个 无符号的 int 整数类型mysql create table t3(id int(1) unsigned);Query OK,0 rows affected (0.01sec)mysql desct3;---------------------------------------------------| Field | Type | Null | Key | Default | Extra |---------------------------------------------------| id | int(1) unsigned | YES | | NULL | |---------------------------------------------------1 row in set (0.00 sec)mysql insert into t3 values(25555555);Query OK,1 row affected (0.00sec)mysql select * fromt3;----------| id |----------| 25555555 |----------1 row in set (0.00sec)整数类型 最大 4个字节存储无符号int类型 最大 这个数 4294967295 无符号范围0-4294967295mysql insert into t3 values(25555555555555555555555555555555555);Query OK,1 row affected, 2 warnings (0.00sec)mysql select * fromt3;------------| id |------------| 25555555 || 4294967295 |------------2 rows in set (0.00 sec)自己定义宽度的 int(1) 没有限制现在存储 因为mysql 不管是 tinyint 、int、bigint 整数类型 都不用设置宽度的整数类型的那个设置宽度 不是存储宽度而是显示宽度对于tinyint、int、bigint的存储宽度 mysql已经固定死了例如用tinyint mysql只用1个字节int用4个字节、bigint8个字节能改变的只有显示宽度显示宽度设置5int 最大存储宽度是4个字节mysql create table t4(id int(5) unsigned);Query OK,0 rows affected (0.01sec)mysqlshow tables;---------------| Tables_in_db4 |---------------| t1 || t2 || t3 || t4 |---------------4 rows in set (0.00sec)mysql desc t4;---------------------------------------------------| Field | Type | Null | Key | Default | Extra |---------------------------------------------------| id | int(5) unsigned | YES | | NULL | |---------------------------------------------------1 row in set (0.00 sec)mysql insert into t4 values(1),(255);Query OK,2 rows affected (0.01sec)Records:2 Duplicates: 0 Warnings: 0mysql select * fromt4;------| id |------| 1 || 255 |------2 rows in set (0.00 sec)显示宽度 是查询表的时候显示的结果的宽度用zerofill测试整数类型的显示宽度再创建一张表t5 加上zerofill用0填充加上这个可以看到显示宽度意思mysql create table t5(id int(5) zerofill);Query OK,0 rows affected (0.01sec)mysql insert into t5 values(1),(2);Query OK,2 rows affected (0.00sec)Records:2 Duplicates: 0 Warnings: 0mysqlmysql select * fromt5;-------| id |-------| 00001 || 00002 |-------2 rows in set (0.00 sec)如果插入的记录的宽度 超过设置的显示宽度他会正常显示mysql insert into t5 values(111111111111111111111111111111111111111111);Query OK,1 row affected, 2 warnings (0.00sec)mysql select * fromt5;------------| id |------------| 00001 || 00002 || 4294967295 |------------3 rows in set (0.00 sec)这个是显示宽度不设置宽度时候mysql create table t6(id intunsigned);Query OK,0 rows affected (0.01sec)mysql desct6;----------------------------------------------------| Field | Type | Null | Key | Default | Extra |----------------------------------------------------| id | int(10) unsigned | YES | | NULL | |----------------------------------------------------1 row in set (0.00 sec)无符号int整数类型默认宽度是10字节有符号int整数类型默认宽度是11字节默认不加任何东西就是 有符号int整数类型mysql create table t7(id int);Query OK,0 rows affected (0.02sec)mysql desct7;-------------------------------------------| Field | Type | Null | Key | Default | Extra |-------------------------------------------| id | int(11) | YES | | NULL | |-------------------------------------------1 row in set (0.00 sec)注意为该类型指定宽度时仅仅只是指定查询结果的显示宽度与存储范围无关存储范围如下其实我们完全没必要为整数类型指定宽度使用默认的就可以了默认的显示宽度都是在最大值的基础上加1对于整数类型 没有必要设置宽度 设置的宽度是显示宽度对于其他类型来说设置的宽度是 存储宽度int的存储宽度是4个Bytes即32个bit即2**32无符号最大值为4294967296-1有符号最大值2147483648-1有符号和无符号的最大数字需要的显示宽度均为10而针对有符号的最小值则需要11位才能显示完全所以int类型默认的显示宽度为11是非常合理的最后整形类型其实没有必要指定显示宽度使用默认的就ok