Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 相同建表语句tidb系统表information_schema.columns中NUMERIC_PRECISION字段精度不一致问题
[TiDB Usage Environment] Production and Testing
[TiDB Version] V5.4.1
[Reproduction Path] Create the same table in MySQL and TiDB
create table testtype
(
test_int int(2),
test_smallint smallint(1),
test_mediumint mediumint(2),
test_bigint bigint(3)
);
MySQL Version: 5.6.19
[Encountered Problem: Phenomenon and Impact]
The NUMERIC_PRECISION values in the information_schema.columns system table are inconsistent for the same table creation statement.
TiDB:
MySQL:
Is this difference designed due to some special functionality in TiDB?
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]
In TiDB, the NUMERIC_PRECISION value does not match the actual precision that can be stored. For example, test_bigint bigint(3) has a precision of 3, but it can actually store data exceeding the precision of 3.
I’ve researched this value and found it to be useless. For int type, there’s no difference between writing 1 and writing 100. Int, bigint, etc., all have fixed precision.
It shouldn’t have much impact.
Precision issues have always existed, right?
The explanation suggests that it can store more than 3 decimal places, but it only displays 3 decimal places. I haven’t tested it myself, you can give it a try.
Got it, I’ll test it myself when I have time.
This only affects display, not storage, as I recall.
You can check the MySQL official website.
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html
As expected, we still need to refer to the official documentation.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.