Precision of SQL data types
The precision of a numeric column or parameter refers to the maximum number of digits that are used by the data type of the column or parameter. The precision of a non-numeric column or parameter generally refers to the maximum length or the defined length of the column or parameter.
The following table defines the precision for each SQL data type.
| fSqlType | Precision |
|---|---|
|
The defined number of characters for the column or parameter. For example, the precision of a column defined as CHAR(10) is 10. |
| SQL_LONGVARCHAR | The maximum length, in characters, of the column or parameter.1 |
|
The defined maximum number of digits. For example, the precision of a column defined as NUMERIC(10,3) is 10. |
| SQL_DECFLOAT | 16 if the column is defined as DECFLOAT(16). 34 if the column is defined as DECFLOAT(34). |
| SQL_SMALLINT2 | 5 |
| SQL_INTEGER2 | 10 |
| SQL_BIGINT2 | 19 |
| SQL_FLOAT2 | 15 |
| SQL_REAL2 | 7 |
| SQL_ROWID | 40 |
| SQL_DOUBLE2 | 15 |
|
The defined length, in characters, of the column or parameter. For example, the precision of a column defined as CHAR(10) FOR BIT DATA, is 10. |
| SQL_LONGVARBINARY | The maximum length, in characters, of the column or parameter. |
| SQL_TYPE_DATE2 | 10 (the number of characters in the yyyy-mm-dd format). |
| SQL_TYPE_TIME2 | 8 (the number of characters in the hh:mm:ss format). |
| SQL_TYPE_TIMESTAMP | The
number of characters in the #yyyy-mm-dd hh:mm:ss[.ffffffffffff]” or
#yyyy-mm-dd.hh.mm.ss[.ffffffffffff]” format that is used by the TIMESTAMP
data type. For example,
if a timestamp does not use seconds or fractional seconds, the precision
is 16 (the number of characters in the "yyyy-mm-dd hh:mm” format).
If a timestamp uses millionths of a second, the precision is 26 (the
number of characters in the "yyyy-mm-dd hh:mm:ss.ffffff” format). The
maximum for fractional seconds is 12 digits.![]() |
| SQL_TYPE_TIMESTAMP_WITH_TIMEZONE | |
| SQL_GRAPHIC SQL_VARGRAPHIC SQL_DBCLOB | The defined length, in characters, of the column or parameter. For example, the precision of a column defined as GRAPHIC(10) is 10. |
| SQL_LONGVARGRAPHIC | The maximum length, in characters, of the column or parameter. |
| SQL_XML2 | 0 |
| Notes:
|
|
The
number of characters in the #yyyy-mm-dd hh:mm:ss[.ffffffffffff]” or
#yyyy-mm-dd.hh.mm.ss[.ffffffffffff]” format that is used by the TIMESTAMP
data type.