What does the first argument to the MySQL Decimal function do?

Using MySQL 5.0.27

This query is: SELECT CAST ('543.21' AS DECIMAL (100,2))

returns 543.21

And this one: SELECT CAST ('543.21' AS DECIMAL (2,2))

In fact, it’s hard for me to understand what effect the parameter has. I use it to combine numeric values ​​in a varchar column (for old reasons !!) and round to two decimal places.

Should I just pick a large number?

+3
source share
1 answer

It describes how many full digits a field (or variable) can store. DECIMAL (100,2) - 100 full digits, 98 before, 2 after the decimal separator DECIMAL (2,2) 2 digits, 0 before, 2 after the decimal separator

: http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

[]

ROUND().

+5

Source: https://habr.com/ru/post/1757162/


All Articles