Warning
Error Code:
3860
MySQL Error 3860: Deprecated Integer Width Usage
Description
This warning indicates that your SQL schema or query is using the deprecated integer display width syntax (e.g., `INT(11)`). While currently a warning, this syntax will be removed in a future MySQL release, meaning such definitions will eventually become invalid.
Error Message
Integer display width is deprecated and will be removed in a future release.
Known Causes
3 known causesExplicit Display Width Definition
Creating or altering table schemas that explicitly define a display width for integer data types, such as `INT(11)` or `TINYINT(4)`.
Legacy SQL Scripts
Executing older SQL scripts, migration files, or database dumps that still contain the deprecated integer display width syntax.
ORM/Schema Generation Tools
Using Object-Relational Mappers (ORMs) or other database schema generation tools that are configured to output integer types with explicit display widths.
Solutions
3 solutions available1. Remove Explicit Display Width from New Table Definitions easy
Update SQL DDL to exclude display width modifiers for integer types.
1
When creating new tables, ensure that you do not specify a display width for integer types (e.g., INT(11), BIGINT(20)). The display width is ignored by MySQL and is considered deprecated.
CREATE TABLE example_table (
id INT PRIMARY KEY,
quantity INT
);
2
If you are using an ORM or database schema generation tool, configure it to avoid generating display width for integer columns.
Example configuration for some ORMs might involve setting a specific option like `integer_display_width = false` or similar. Refer to your ORM's documentation.
2. Modify Existing Table Definitions to Remove Display Width medium
Alter existing table schemas to remove deprecated display width specifications.
1
Identify all columns in your database that use integer types with explicit display widths. You can use a query like this to find them:
SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE IN ('tinyint', 'smallint', 'mediumint', 'int', 'bigint')
AND COLUMN_TYPE LIKE '%(%)' AND COLUMN_TYPE NOT LIKE '%unsigned%' AND COLUMN_TYPE NOT LIKE '%zerofill%';
2
For each identified column, use an `ALTER TABLE` statement to modify the column definition and remove the display width. For example, if you have `quantity INT(11)`:
ALTER TABLE your_table_name MODIFY COLUMN quantity INT;
3
Be cautious when running `ALTER TABLE` statements on large tables in production. It's recommended to perform these changes during a maintenance window or use online schema change tools if available.
N/A
3. Configure MySQL Server to Suppress Warnings (Temporary Workaround) easy
Temporarily disable the deprecation warning for integer display width.
1
You can temporarily suppress this warning by setting the `sql_mode` server variable. This is not a permanent solution to the deprecation but will stop the error messages.
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
-- Or, remove 'STRICT_TRANS_TABLES' and 'STRICT_ALL_TABLES' if they are present and causing issues.
2
To make this change permanent, you need to modify your MySQL configuration file (e.g., `my.cnf` or `my.ini`). Add or modify the `sql_mode` parameter under the `[mysqld]` section.
[mysqld]
sql_mode = "NO_ENGINE_SUBSTITUTION"
3
After modifying the configuration file, restart the MySQL server for the changes to take effect.
sudo systemctl restart mysql # Or your specific service name