Display size of SQL data types
The display size of a column is the maximum number of bytes that are needed to display data in character form.
The following table defines the display size for each SQL data type
fSqlType | Display size |
---|---|
SQL_CHAR SQL_VARCHAR, SQL_CLOB | The defined length, in bytes, of the column. For example, the display size of a column defined as CHAR(10) is 10. |
SQL_LONGVARCHAR | The maximum length, in bytes, of the column. |
SQL_DECFLOAT | 23 bytes if the column is defined as DECFLOAT(16). 42 bytes if the column is defined as DECFLOAT(34). |
SQL_DECIMAL, SQL_NUMERIC | The precision of the column plus two bytes (a sign, precision digits, and a decimal point). For example, the display size of a column defined as NUMERIC(10,3) is 12. |
SQL_SMALLINT | 6 bytes (a sign and 5 digits). |
SQL_INTEGER | 11 bytes (a sign and 10 digits). |
SQL_BIGINT | 20 bytes (a sign and 19 digits). |
SQL_REAL | 13 bytes (a sign, 7 digits, a decimal point, the letter E, a sign, and 2 digits). |
SQL_ROWID | 40 bytes |
SQL_FLOAT, SQL_DOUBLE | 22 bytes (a sign, 15 digits, a decimal point, the letter E, a sign, and 3 digits). |
SQL_BINARY, SQL_VARBINARY, SQL_BLOB | The defined length of the column times 2 bytes. (Each binary byte is represented by a 2 digit hexadecimal number.) For example, the display size of a column defined as CHAR(10) FOR BIT DATA is 20. |
SQL_LONGVARBINARY | The maximum length of the column times 2 bytes. |
SQL_TYPE_DATE | 10 bytes (a date in the format yyyy-mm-dd). |
SQL_TYPE_TIME | 8 bytes (a time in the format hh:mm:ss). |
SQL_TYPE_TIMESTAMP | 19 bytes (if the scale of the timestamp is 0) or
20 bytes plus the scale of the timestamp (if the scale is greater
than 0). This
value is the number of characters in the #yyyy-mm-dd hh:mm:ss[.ffffffffffff]
or #yyyy-mm-dd.hh.mm.ss[.ffffffffffff] format. For
example, the display size of a column storing millionths of a second
is 23 bytes (the number of characters in "yyyy-mm-dd hh:mm:ss.ffffff”). The
maximum for fractional seconds is 12 digits. You can retrieve
the display size of a timestamp column through the COLUMN_SIZE column
that is returned by SQLColumns() or SQLSpecialColumns() .
You can retrieve the display size of a SQL_TYPE_TIMESTAMP stored procedure
parameter through the COLUMN_SIZE column that is returned by SQLProcedureColumns() . |
![]() ![]() |
![]() ![]() |
SQL_GRAPHIC, SQL_VARGRAPHIC, SQL_DBCLOB | The defined length of the column or parameter times two bytes. For example, the display size of a column defined as GRAPHIC(10) is 20 bytes. |
SQL_LONGVARGRAPHIC | The maximum length, in bytes, of the column or parameter. |
SQL_XML | 0 |