![]() ![]() To declare a column of type numeric use the syntax: NUMERIC( precision, scale) Integers can be considered to have a scale of zero.īoth the maximum precision and the maximum scale of a numeric column can be configured. The precision must be positive, the scale zero or positive. Without any precision or scale creates a column in which numeric values of any precision and scale can be stored, up to the implementation limit on precision. ![]() A column of this kind will not coerce input values to any particular scale, whereas numeric columns with a declared scale will coerce input values to that scale. If you're concerned about portability, always specify the precision and scale explicitly.) (The SQL standard requires a default scale of 0, i.e., coercion to integer precision. Note: The maximum allowed precision when explicitly specified in the type declaration is 1000 NUMERIC without a specified precision is subject to the limits described in Table 8-2. If the scale of a value to be stored is greater than the declared scale of the column, the system will round the value to the specified number of fractional digits. Then, if the number of digits to the left of the decimal point exceeds the declared precision minus the declared scale, an error is raised. ![]() Numeric values are physically stored without any extra leading or trailing zeroes. Thus, the declared precision and scale of a column are maximums, not fixed allocations. (In this sense the numeric type is more akin to varchar( n) than to char( n).) The actual storage requirement is two bytes for each group of four decimal digits, plus three to eight bytes overhead. In addition to ordinary numeric values, the numeric type allows the special value NaN, meaning "not-a-number". When writing this value as a constant in an SQL command, you must put quotes around it, for example UPDATE table SET x = 'NaN'. On input, the string NaN is recognized in a case-insensitive manner. The data types real and double precision are inexact, variable-precision numeric types. In practice, these types are usually implementations of IEEE Standard 754 for Binary Floating-Point Arithmetic (single and double precision, respectively), to the extent that the underlying processor, operating system, and compiler support it. Inexact means that some values cannot be converted exactly to the internal format and are stored as approximations, so that storing and retrieving a value might show slight discrepancies. ![]()
0 Comments
Leave a Reply. |