In Oracle Database, fields like this:

      example number(6,4) not null;

Indicate that I'm reserving 6 digits for this column, 4 that are being used from the point to the right and 2 for the point to the left.

Is this the same in MySQL?

Thanks!!! I know this is basic but I have some time working on databases and always this question...

  • 1
    Numbers do not have format until they are printed on screen or formatted otherwise; what you're talking about is scale and precision. – mustaccio Jan 10 '19 at 20:59

It's always a good idea to check the MySQL documentation for quick answers like this.

In a DECIMAL column declaration, the precision and scale can be (and usually is) specified; for example:

salary DECIMAL(5,2)

In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point.

The decimal type has these constraints on scale and precision:

The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments are as follows:

  • M is the maximum number of digits (the precision). It has a range of 1 to 65.

  • D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.

  • Thanks! and What is the limit from the scale ? – jimmy marroquin Jan 10 '19 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.