is float(0) SQL datatype valid?
I was under the impression that the minimum value for n in float(n) had to be 1.
I've not seen a "float(0)" data type before so I wonder if开发者_JAVA百科 it's valid.
This question might not be terribly meaningful without specifying an implementation.
In SQL Server, for example, float's minimum precision is 1.
Where n is the number of bits that are used to store the mantissa of the float number in scientific notation and, therefore, dictates the precision and storage size. If n is specified, it must be a value between 1 and 53. The default value of n is 53.
In MySQL, on the other hand, float(0)
is valid syntax, but it doesn't sound terribly meaningful. From the specification:
MySQL also supports this optional precision specification, but the precision value is used only to determine storage size. A precision from 0 to 23 results in a four-byte single-precision FLOAT column. A precision from 24 to 53 results in an eight-byte double-precision DOUBLE column.
Oracle has a FLOAT datatype, but it appears to just be an alias for NUMBER, and its minimum precision is 1:
A subtype of the NUMBER datatype having precision p. A FLOAT value is represented internally as NUMBER. The precision p can range from 1 to 126 binary digits. A FLOAT value requires from 1 to 22 bytes.
So you can see that the answer is highly implementation-specific. I'm not sure the ANSI SQL standards specify FLOAT precision. It's possible they do not.
it isn't valid, because you need to declare the size of the datatype. Obviously can't be zero.
Both Oracle and MS SQL state that minimum value for float
precision is 1.
This makes sense: it's the number of decimal places you want your floating point number to support. Zero decimal places would mean no value at all.
According to this:
http://msdn.microsoft.com/en-us/library/ms173773.aspx
It is not valid, at least on SQL Server. 0 would represent zero bits, and it's hard to squeeze data into something that has zero storage space.
精彩评论