Different databases implicitly type numeric literals differently,
- MySQL types
1.0
asdecimal(2,1)
- PostgreSQL types
1.0
asnumeric
Which one of these is correct?
datatypessql-standard
Different databases implicitly type numeric literals differently,
1.0
as decimal(2,1)
1.0
as numeric
Which one of these is correct?
Best Answer
Both are correct and compliant on storage from literals. There are two types of numeric literals in the spec's eyes,
<exact numeric literal>
<approximate numeric literals>
floating point, triggered by the use of Scientific Notation (withE
ore
)For exact numeric literals (ENL),
For approximate numeric literals (ANL),
Meaning the type merely has to be able to hold the literal, the rest is left to the implementation.
Taken from the SQL 2011n spec
See also