Error
Error Code:
1426
MySQL Error 1426: Precision Exceeds Maximum
Description
This error occurs when you attempt to define a numeric column, typically `DECIMAL` or `NUMERIC`, with a precision value that is larger than the maximum supported by MySQL. It prevents table creation or alteration operations from completing successfully.
Error Message
Too-big precision %d specified for '%s'. Maximum is %lu.
Known Causes
3 known causesOverly Large Numeric Precision
The specified total number of digits (precision) for a `DECIMAL` or `NUMERIC` column exceeds MySQL's maximum limit, which is typically 65.
Precision/Scale Misinterpretation
Users sometimes mistakenly specify the scale value (digits after decimal) in the precision parameter, leading to an excessively large total precision.
Database Migration Incompatibility
Schema definitions migrated from other database systems might contain precision values that are valid elsewhere but exceed MySQL's limitations.
Solutions
3 solutions available1. Reduce Precision in Numeric Data Types easy
Adjust the precision of DECIMAL or FLOAT columns to be within MySQL's limits.
1
Identify the column causing the error. The error message will usually tell you the name of the column ('%s').
2
Determine the maximum allowed precision for the data type. For DECIMAL, the maximum precision is 65. For FLOAT and DOUBLE, the precision is determined by the hardware.
3
Modify the table schema to reduce the precision of the problematic column. For example, if you have `DECIMAL(70, 10)`, reduce it to `DECIMAL(65, 10)` or a lower value that suits your needs.
ALTER TABLE your_table_name MODIFY COLUMN your_column_name DECIMAL(65, 10);
4
If the error occurs during table creation, adjust the precision in your `CREATE TABLE` statement.
CREATE TABLE your_table_name (
your_column_name DECIMAL(65, 10)
);
2. Use Appropriate Numeric Data Types easy
Select a numeric data type that inherently supports the required precision.
1
Analyze the range and precision of the data you intend to store. If you are storing very large numbers or require high precision, consider if `DECIMAL` is the best choice, or if another type might suffice.
2
For general-purpose floating-point numbers, `DOUBLE` or `FLOAT` might be suitable, though they have inherent precision limitations compared to `DECIMAL` for exact representations. If exact precision is critical, `DECIMAL` is preferred, but you must respect its limits.
3
If you encounter this error with `DECIMAL`, and your data truly requires more than 65 digits of precision, you may need to reconsider your data model or use external storage solutions for such large numbers.
3. Review Stored Procedures and Functions medium
Inspect stored code for excessively high precision definitions.
1
Examine the definitions of stored procedures, functions, and triggers in your database.
2
Look for any variable declarations or parameter definitions that use `DECIMAL` or other numeric types with precision exceeding MySQL's maximum limits (e.g., `DECIMAL(70, 20)`).
SHOW CREATE PROCEDURE your_procedure_name;
SHOW CREATE FUNCTION your_function_name;
3
Modify the stored code to use a valid precision for the numeric types.
-- Example modification within a stored procedure:
DECLARE my_variable DECIMAL(65, 10);
4
Recompile or re-save the modified stored code.
DELIMITER $$
CREATE PROCEDURE ...
-- ... modify precision here ...
$$