Data Types for Qt-supported Database Systems

This table shows the recommended data types for extracting data from the databases supported in Qt. Note that types used in Qt are not necessarily valid as input types to a specific database system. e.g., A double might work perfectly as input for floating point records in a particular database, but not necessarily as a storage format for output from that database, because it would be stored with 64-bit precision in C++.

IBM DB2 Data Types

IBM DB2 data typeSQL type descriptionRecommended input (C++ or Qt data type)
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT64-bit signed integertypedef qint64
REAL32-bit Single-precision floating pointtypedef qreal
DOUBLE PRECISION64-bit Double-precision floating pointMapped to QString for high precision doubles, otherwise qreal
FLOAT64-bit Double-precision floating pointtypedef qreal
CHARFixed-length, null-terminated character stringMapped to QString
VARCHARNull-terminated varying length stringMapped to QString
LONG VARCHARNot null-terminated varying length character stringMapped to QString
BLOBNot null-terminated varying binary string with 4-byte string length indicatorMapped to QByteArray
CLOBCharacter large string objectMapped to QString
DATENull-terminated character string of the following format: yyyy-mm-ddMapped to QDate
TIMENull-terminated character string of the following format: hh.mm.ssMapped to QTime
TIMESTAMPNull-terminated character string of the following format: yyyy-mm-dd-hh.mm.ss.nnnnnnMapped to QDateTime

Borland InterBase Data Types

Borland InterBase data typeSQL type descriptionRecommended input (C++ or Qt data type)
BOOLEANBooleanbool
TINYINT8 bit signed integertypedef qint8
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT LONG64-bit signed integertypedef qint64
REAL FLOAT32-bit floating pointtypedef qreal
FLOAT64-bit floating pointtypedef qreal
DOUBLE64-bit floating pointtypedef qreal
DOUBLE PRECISION64-bit Double-precision floating pointMapped to QString for high precision doubles, otherwise qreal
VARCHAR STRINGCharacter string, UnicodeMapped to QString
CLOBCharacter large string objectMapped to QString
DATEDisplays date. Format: 'yyyy-mm-dd'Mapped to QDate
TIMEDisplays time. Format is 'hh:mm:ss' in 24-hour formatMapped to QTime
TIMESTAMPDisplays a timestamp. Format is 'yyyy-mm-dd hh:mm:ss'Mapped to QDateTime

MySQL Data Types

MySQL data typeSQL type descriptionRecommended input (C++ or Qt data type)
TINYINT8 bit signed integertypedef qint8
TINYINT UNSIGNED8 bit unsigned integertypedef quint8
SMALLINT16-bit signed integertypedef qint16
SMALLINT UNSIGNED16-bit unsigned integertypedef quint16
INT32-bit signed integertypedef qint32
INT UNSIGNED32-bit unsigned integertypedef quint32
BIGINT64-bit signed integertypedef qint64
FLOAT32-bit Floating Pointtypedef qreal
DOUBLE64-bit Floating PointMapped to QString for high precision doubles, otherwise qreal
CHARCharacter stringMapped to QString
VARCHARCharacter stringMapped to QString
TINYTEXTCharacter stringMapped to QString
TEXTCharacter stringMapped to QString
MEDIUMTEXTCharacter stringMapped to QString
LONGTEXTCharacter stringMapped to QString
CLOBCharacter large string objectMapped to QString
all BLOB typesBLOBMapped to QByteArray
DATEDate without TimeMapped to QDate
DATETIMEDate and TimeMapped to QDateTime
TIMESTAMPDate and TimeMapped to QDateTime
TIMETimeMapped to QTime
YEARYear (int)Mapped to QDateTime
ENUMEnumeration of Value SetMapped to QString

Oracle Call Interface Data Types

Oracle Call Interface data typeSQL type descriptionRecommended input (C++ or Qt data type)
NUMBERFLOAT, DOUBLE, PRECISIONc REALMapped to QString for high precision doubles, otherwise qreal
NUMBER(38)INTEGER INT SMALLINTtypedef qint8/16/32/64
NUMBER(p,s)NUMERIC(p,s) DECIMAL(p,s)aMapped to QString
NVARCHAR2(n)Character string (NATIONAL CHARACTER VARYING(n) NATIONAL CHAR VARYING(n) NCHAR VARYING(n))Mapped to QString
NCHAR(n)Character string (NATIONAL CHARACTER(n) NATIONAL CHAR(n) NCHAR(n))Mapped to QString
CHAR(n)Character string (CHARACTER(n) CHAR(n))Mapped to QString
CLOBCharacter large string objectMapped to QString
BLOBA binary large objectMapped to QByteArray
TIMESTAMPYear, month, and day values of date, as well as hour, minute, and second values of timeMapped to QDateTime

ODBC Data Types

ODBC data typeSQL type descriptionRecommended input (C++ or Qt data type)
BITBooleanBOOL
TINYINT8 bit integertypedef qint8
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT64-bit signed integertypedef qint64
REAL32-bit Single-precision floating pointtypedef qreal
FLOAT64-bit Double floating pointtypedef qreal
DOUBLE64-bit Double floating pointMapped to QString for high precision doubles, otherwise qreal
CHARCharacter stringMapped to QString
VARCHARCharacter stringMapped to QString
LONGVARCHARCharacter stringMapped to QString
CLOBCharacter large string objectMapped to QString
DATECharacter stringMapped to QDate
TIMECharacter Time, Character stringMapped to QTime
TIMESTAMPCharacter Time, Character stringMapped to QDateTime

PostgreSQL Data Types

PostgreSQL data typeSQL type descriptionRecommended input (C++ or Qt data type)
BOOLEANBooleanbool
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT64-bit signed integertypedef qint64
REAL32-bit variable-precision floating pointtypedef qreal
DOUBLE PRECISION64-bit variable-precision floating pointMapped to QString for high precision doubles, otherwise qreal
DECIMAL VARIABLEuser-specified precision, exacttypedef qreal
NUMERIC VARIABLEuser-specified precision, exacttypedef qreal
VARCHARvariable-length character stringMapped to QString
CHARACTERCharacter string of fixed-lengthMapped to QString
TEXTCharacter string of variable-lengthMapped to QString
CLOBCharacter large string objectMapped to QString
TIMESTAMP8 bytes, both date and timeMapped to QDateTime
TIMESTAMP8 bytes, both date and time, with time zoneMapped to QDateTime
DATE4 bytes, dates onlyMapped to QDate
TIME8 bytes, times of day only 00:00:00.00 - 23:59:59.99Mapped to QTime
TIME12 bytes times of day only, with time zone 00:00:00.00+12Mapped to QDateTime

QSQLITE SQLite version 3 Data Types

QSQLITE SQLite version 3 data typeSQL type descriptionRecommended input (C++ or Qt data type)
NULLNULL value.NULL
INTEGERSigned integer, stored in 8, 16, 24, 32, 48, or 64-bits depending on the magnitude of the value.typedef qint8/16/32/64
REAL64-bit floating point value.typedef qreal
TEXTCharacter string (UTF-8, UTF-16BE or UTF-16-LE).Mapped to QString
CLOBCharacter large string objectMapped to QString
BLOBThe value is a BLOB of data, stored exactly as it was input.Mapped to QByteArray

Mimer SQL Data Types

Mimer SQL typeSQL type descriptionRecommended input (C++ or Qt data type)
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
INTEGER(n)Integer with up to 45 digits precisionMapped to QString
BIGINT64-bit signed integertypedef qint64
REAL32-bit Single-precision IEEE floating pointtypedef float
DOUBLE PRECISION64-bit Double-precision IEEE floating pointMapped to QString for high precision doubles, otherwise qreal
FLOAT64-bit Double-precision IEEE floating pointMapped to QString for high precision doubles, otherwise qreal
FLOAT(n)Floating point with up to 45 digits precisionMapped to QString
DECIMAL(p,s)Decimal with up to 45 digits precision and scaleMapped to QString
CHARFixed-length character Latin-1 string (CHAR or character)Mapped to QString
VARCHARVariable length Latin-1 string (VARCHAR or CHARACTER VARYING)Mapped to QString
NCHARFixed-length Unicode string (NCHAR or NATIONAL CHARACTER)Mapped to QString
NVARCHARVariable length Unicode string (NVARCHAR or NATIONAL CHARACTER VARYING)Mapped to QString
BINARYFixed length binary dataMapped to QByteArray
VARBINARYVariable length binary data (VARBINARY or BINARY VARYING)Mapped to QByteArray
BLOBBinary large object (BLOB or BINARY LARGE OBJECT)Mapped to QByteArray
CLOBLatin-1 character large object (CLOB or CHARACTER LARGE OBJECT)Mapped to QString
NCLOBUnicode character large object (NCLOB or NATIONAL CHARACTER LARGE OBJECT)Mapped to QString
DATEDate consisting of year, month, and dayMapped to QDate
TIMETime consisting of hours, minute, seconds with optional fractional secondsMapped to QTime
TIMESTAMPDate and time with optional fractional secondsMapped to QDateTime
BUILTIN.UUIDUniversally unique identifierMapped to QUuid
BOOLEANBooleanbool
INTERVAL YEAR(7)Year, format '±yyyyyyy' (max precision)Mapped to QString
INTERVAL YEAR(7) TO MONTHYear to month, format '±yyyyyyy-mm' (max precision)Mapped to QString
INTERVAL MONTH(7)Month, format '±mmmmmmm' (max precision)Mapped to QString
INTERVAL DAY(7)Day, format '±ddddddd' (max precision)Mapped to QString
INTERVAL DAY(7) TO HOURDay to hour, format '±ddddddd hh' (max precision)Mapped to QString
INTERVAL DAY(7) TO MINUTEDay to minute, format '±ddddddd hh:mm' (max precision)Mapped to QString
INTERVAL DAY(7) TO SECOND(9)Day to second, format '±ddddddd hh:mm:ss[.fffffffff]' (max precision)Mapped to QString
INTERVAL HOUR(8)Hour, format '±hhhhhhhh' (max precision)Mapped to QString
INTERVAL HOUR(8) TO MINUTEHour to minute, format '±hhhhhhhh:mm' (max precision)Mapped to QString
INTERVAL HOUR(8) TO SECOND(9)Hour to second, format '±hhhhhhhh:mm:ss[.fffffffff]' (max precision)Mapped to QString
INTERVAL MINUTE(10)Minute, format '±mmmmmmmmmm' (max precision)Mapped to QString
INTERVAL MINUTE(10) TO SECOND(9)Minute to second, format '±mmmmmmmmmm:ss[.fffffffff]' (max precision)Mapped to QString
INTERVAL SECOND(12,9)Second, format '±ssssssssssss[.fffffffff]' (max precision)Mapped to QString