MySQL 8忽略整数长度 [英] MySQL 8 ignoring integer lengths
问题描述
我有一个运行在Docker容器中并使用InnoDB引擎的MySQL 8.0.19.我注意到表整数字段的长度被忽略了.
I have a MySQL 8.0.19 running in a Docker container and using the InnoDB engine. I have noticed that table integer field lengths are getting ignored.
无论运行CREATE还是ALTER查询,整数数据类型都会出现问题
The issue occurs with integer datatypes regardless if running a CREATE or ALTER query
CREATE TABLE `test` (
`id` int DEFAULT NULL,
`text_field` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`decimal_field` decimal(6,2) DEFAULT NULL,
`int_field` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
在我的MySQL客户端(Navicat)中,长度显示为0,但是如果在控制台中使用SHOW FULL COLUMNS FROM
test ;
The lengths are showing as 0 in my MySQL client (Navicat), but the same occurs if checking in the console with SHOW FULL COLUMNS FROM
test;
mysql> SHOW FULL COLUMNS FROM `test`;
+---------------+--------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+---------------+--------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
| id | int | NULL | YES | | NULL | | select,insert,update,references | |
| text_field | varchar(20) | utf8mb4_unicode_ci | YES | | NULL | | select,insert,update,references | |
| decimal_field | decimal(6,2) | NULL | YES | | NULL | | select,insert,update,references | |
| int_field | int | NULL | YES | | NULL | | select,insert,update,references | |
+---------------+--------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
类型"列的两个整数字段应该显示int(11),但不是.
The Type column should be showing int(11) for the two integer fields, but it isn't.
这与我的MySQL设置中的内容有关吗?如果是,则必须更改哪个变量?
Is this related to something in my MySQL settings, and if so, which variable would have to be changed?